Package com.gwtplatform.mvp.shared.proxy

Examples of com.gwtplatform.mvp.shared.proxy.PlaceRequest


    private static void parseSingleToken(List<PlaceRequest> places, String token) {

        if(token.contains(";")) // parametrized?
        {
            StringTokenizer params = new StringTokenizer(token, ";");
            PlaceRequest request = null;
            while(params.hasMoreTokens())
            {
                String tok = params.nextToken();
                if(tok.contains("="))
                {
                    if(null==request) break;

                    // parameter
                    String[] parameter = tok.split("=");
                    request = request.with(parameter[0], parameter[1]);
                }
                else
                {
                    // address
                    request = new PlaceRequest(tok);

                }
            }

            // exit, either wrong token or different formatter
            if(null==request)
                throw new IllegalArgumentException("Illegal token: "+token);

            places.add(request);
        }
        else
        {
            places.add(new PlaceRequest(token));
        }
    }
View Full Code Here


        int hierarchySize = placeHierarchy.size();
        if (hierarchySize == 0) {
            unlock();
            revealDefaultPlace();
        } else {
            PlaceRequest request = placeHierarchy.get(hierarchySize - 1);
            doRevealPlace(request, true);
        }
    }
View Full Code Here

            @Override
            public void onPlaceRequest(PlaceRequestInternalEvent event) {
                if (event.isHandled()) {
                    return;
                }
                PlaceRequest request = event.getRequest();
                if (matchesRequest(request)) {
                    event.setHandled();
                    if (canReveal()) {
                        handleRequest(request, event.shouldUpdateBrowserHistory());
                    } else {
                        event.setUnauthorized();
                    }
                }
            }
        });
        addRegisteredHandler(GetPlaceTitleEvent.getType(), new GetPlaceTitleHandler() {
            @Override
            public void onGetPlaceTitle(GetPlaceTitleEvent event) {
                if (event.isHandled()) {
                    return;
                }
                PlaceRequest request = event.getRequest();
                if (matchesRequest(request)) {
                    if (canReveal()) {
                        event.setHandled();
                        getPlaceTitle(event);
                    }
View Full Code Here

                // in case it wants to fire some events. That's why we will do this in a
                // deferred command.
                addDeferredCommand(new Command() {
                    @Override
                    public void execute() {
                        PlaceRequest originalRequest = placeManager.getCurrentPlaceRequest();
                        presenter.prepareFromRequest(request);
                        if (originalRequest == placeManager.getCurrentPlaceRequest()) {
                            // User did not manually update place request in prepareFromRequest, update it here.
                            placeManager.updateHistory(request, updateBrowserUrl);
                        }
View Full Code Here

        CarDto carDto = mock(CarDto.class);
        given(carDto.getManufacturer()).willReturn(manufacturerDto);
        given(carProxyFactory.create(carDto, carDto.getManufacturer().getName() + carDto.getModel())).willReturn(proxy);
        given(proxy.getNameToken()).willReturn("token");

        PlaceRequest placeRequest = new PlaceRequest.Builder().nameToken("token").build();

        // When
        carsPresenter.onEdit(carDto);

        // Then
View Full Code Here

    }

    @Test
    public void onCreate(PlaceManager placeManager) {
        // Given
        PlaceRequest placeRequest = new PlaceRequest.Builder().nameToken(NameTokens.NEW_CAR).build();

        // When
        carsPresenter.onCreate();

        // Then
View Full Code Here

    DeferredCommandManager deferredCommandManager;

    @Test
    public void placeManagerRevealDefaultPlaceWhenGatekeeperCanNotReveal(DummyPresenterDefault defaultPresenter) {
        // Given
        PlaceRequest placeRequest = new PlaceRequest.Builder().nameToken("dummyNameTokenWithDenyGatekeeper").build();

        // When
        placeManager.revealPlace(placeRequest);
        deferredCommandManager.pump();

        // Then
        List<PlaceRequest> placeHierarchy = placeManager.getCurrentPlaceHierarchy();
        assertEquals(1, placeHierarchy.size());

        PlaceRequest finalPlaceRequest = placeManager.getCurrentPlaceRequest();
        assertEquals(placeHierarchy.get(0), finalPlaceRequest);

        assertEquals("defaultPlace", finalPlaceRequest.getNameToken());
        assertEquals(0, finalPlaceRequest.getParameterNames().size());

        verify(defaultPresenter).prepareFromRequest(finalPlaceRequest);
        verify(defaultPresenter).forceReveal();
    }
View Full Code Here

    @Test
    public void placeManagerRevealRequestPlaceWhenGatekeeperCanReveal(
            DummyPresenterWithGrantGatekeeper presenterWithGatekeeper) {
        // Given
        PlaceRequest placeRequest = new PlaceRequest.Builder().nameToken("dummyNameTokenWithGrantGatekeeper").build();

        // When
        placeManager.revealPlace(placeRequest);
        deferredCommandManager.pump();

        // Then
        List<PlaceRequest> placeHierarchy = placeManager.getCurrentPlaceHierarchy();
        assertEquals(1, placeHierarchy.size());

        PlaceRequest finalPlaceRequest = placeManager.getCurrentPlaceRequest();
        assertEquals(placeHierarchy.get(0), finalPlaceRequest);

        assertEquals("dummyNameTokenWithGrantGatekeeper", finalPlaceRequest.getNameToken());
        assertEquals(0, finalPlaceRequest.getParameterNames().size());

        verify(presenterWithGatekeeper).prepareFromRequest(finalPlaceRequest);
        verify(presenterWithGatekeeper).forceReveal();
    }
View Full Code Here

    @Test
    public void placeManagerRevealDefaultPlaceWhenGatekeeperWithParamsCanNotReveal(DummyPresenterDefault
            defaultPresenter) {
        // Given
        PlaceRequest placeRequest = new PlaceRequest.Builder().nameToken("dummyNameTokenWithDenyGatekeeperWithParams")
                .build();

        // When
        placeManager.revealPlace(placeRequest);
        deferredCommandManager.pump();

        // Then
        List<PlaceRequest> placeHierarchy = placeManager.getCurrentPlaceHierarchy();
        assertEquals(1, placeHierarchy.size());

        PlaceRequest finalPlaceRequest = placeManager.getCurrentPlaceRequest();
        assertEquals(placeHierarchy.get(0), finalPlaceRequest);

        assertEquals("defaultPlace", finalPlaceRequest.getNameToken());
        assertEquals(0, finalPlaceRequest.getParameterNames().size());

        verify(defaultPresenter).prepareFromRequest(finalPlaceRequest);
        verify(defaultPresenter).forceReveal();
    }
View Full Code Here

    @Test
    public void placeManagerRevealRequestPlaceWhenGatekeeperWithParamsCanReveal(
            DummyPresenterWithGrantGatekeeperWithParams presenter) {
        // Given
        PlaceRequest placeRequest = new PlaceRequest.Builder().nameToken("dummyNameTokenWithGrantGatekeeperWithParams")
                .build();

        // When
        placeManager.revealPlace(placeRequest);
        deferredCommandManager.pump();

        // Then
        List<PlaceRequest> placeHierarchy = placeManager.getCurrentPlaceHierarchy();
        assertEquals(1, placeHierarchy.size());

        PlaceRequest finalPlaceRequest = placeManager.getCurrentPlaceRequest();
        assertEquals(placeHierarchy.get(0), finalPlaceRequest);

        assertEquals("dummyNameTokenWithGrantGatekeeperWithParams", finalPlaceRequest.getNameToken());
        assertEquals(0, finalPlaceRequest.getParameterNames().size());

        verify(presenter).prepareFromRequest(finalPlaceRequest);
        verify(presenter).forceReveal();
    }
View Full Code Here

TOP

Related Classes of com.gwtplatform.mvp.shared.proxy.PlaceRequest

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.