Package org.springframework.richclient.command

Examples of org.springframework.richclient.command.ActionCommand


        String commandId = getDeleteCommandId();
        if( !StringUtils.hasText( commandId ) ) {
            return null;
        }

        final ActionCommand deleteCommand = new ActionCommand( commandId ) {
            protected void doExecuteCommand() {
                maybeDeleteSelectedItems();
            }
        };

        String scid = constructSecurityControllerId( commandId );
        deleteCommand.setSecurityControllerId( scid );
        return (ActionCommand) getCommandConfigurer().configure( deleteCommand );
    }
View Full Code Here


    protected void maybeCreateNewObject() {
        if( getDetailForm().isEditingNewFormObject() ) {
            return; // Already creating a new object, just bail
        }

        final ActionCommand detailNewObjectCommand = detailForm.getNewFormObjectCommand();

        if( getDetailForm().isDirty() ) {
            String title = getMessage( new String[] { getId() + ".dirtyNew.title", "masterForm.dirtyNew.title" } );
            String message = getMessage( new String[] { getId() + ".dirtyNew.message", "masterForm.dirtyNew.message" } );
            ConfirmationDialog dlg = new ConfirmationDialog( title, message ) {
                protected void onConfirm() {
                    // Tell both forms that we are creating a new object
                    detailNewObjectCommand.execute(); // Do subform action first
                    creatingNewObject();
                    detailForm.creatingNewObject();
                }
            };
            dlg.showDialog();
        } else {
            // Tell both forms that we are creating a new object
            detailNewObjectCommand.execute(); // Do subform action first
            creatingNewObject();
            detailForm.creatingNewObject();
        }
    }
View Full Code Here

    }

    public void testStandardViewAdaptsOkCommand() {
        TestDialogPage page = new TestDialogPage();

        ActionCommand okCommand = new ActionCommand("okCommand") {
            protected void doExecuteCommand() {
            }
        };
        ActionCommand cancelCommand = new ActionCommand("cancelCommand") {
            protected void doExecuteCommand() {
            }
        };

        DialogPageUtils.createStandardView(page, okCommand, cancelCommand);
View Full Code Here

    }

    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

    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

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

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

        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

  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

  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

TOP

Related Classes of org.springframework.richclient.command.ActionCommand

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.