Example usage for com.google.gwt.gwtpages.client Pages get

List of usage examples for com.google.gwt.gwtpages.client Pages get

Introduction

In this page you can find the example usage for com.google.gwt.gwtpages.client Pages get.

Prototype

public static Pages get() 

Source Link

Usage

From source file:com.google.gwt.gwtpages.demo.client.GWT_Pages_Demo.java

/**
 * This is the entry point method./*from  w  w w.java 2s  . co m*/
 */
public void onModuleLoad() {
    // composite application presenter for use with the layouts demo page
    CompositeLayoutApplicationPresenter presenter = new CompositeLayoutApplicationPresenter(
            PageConstants.LAYOUT_DEFAULT).register(PageConstants.LAYOUT_DEFAULT, new DefaultLayoutPage())
                    .register(PageConstants.LAYOUT_NONE, new NoLayoutPage())
                    .register(PageConstants.LAYOUT_NAV_RIGHT, new RightNavLayoutPage());

    // initialize the pages settings
    Pages.init((DemoPageLoader) GWT.create(DemoPageLoader.class), // the class responsible for mapping page tokens to pages
            presenter, // the component that will actually render the pages
            new HandlerManager(null), true) // the event bus
            .addDefaultEventHandlers().add(this); // add default behavior if desired

    // make the initial page show up (and check the history token to go directly to a requested page and bypass the start
    // page if necessary
    Pages.get().showStartPage(true);
}

From source file:com.google.gwt.gwtpages.demo.client.GWT_Pages_Demo.java

@Override
public Command onPageEnterFailure(LoadedPageContainer pageLoadResult, PageParameters parameters,
        GotoPageCommand command) {/*from w  ww.j  a  v  a2  s . c  o m*/
    return new Command() {
        @Override
        public void execute() {
            Pages.get().gotoPage(PageConstants.PAGE_500).addHistoryToken(false).execute();
        }
    };

}

From source file:com.google.gwt.gwtpages.demo.client.GWT_Pages_Demo.java

@Override
public Command onPageLoadFailure(String historyToken, Throwable cause) {
    return new Command() {
        @Override// ww  w. j  av a  2  s .co m
        public void execute() {
            Pages.get().gotoPage(PageConstants.PAGE_500).addHistoryToken(false).execute();
        }
    };
}

From source file:com.google.gwt.gwtpages.demo.client.GWT_Pages_Demo.java

@Override
public Command onPageNotFound(String historyToken) {
    return new Command() {
        @Override/*from  ww  w . j  ava  2  s  . co  m*/
        public void execute() {
            Pages.get().gotoPage(PageConstants.PAGE_404).addHistoryToken(false).execute();
        }
    };
}

From source file:com.google.gwt.gwtpages.demo.client.pages.layout.MenuItemsPanel.java

@Override
protected void onAttach() {
    super.onAttach();
    if (!initialized) {
        Pages.get().getEventBus().addHandler(PageShownEvent.TYPE, this);
        initialized = true;/*w ww .  j  a v a 2  s . co m*/
    }
}

From source file:hudson.gwtmarketplace.client.commands.AddProductCommentCommand.java

License:Open Source License

public void execute() {
    if (null != comment && null != comment.getCommentText() && comment.getCommentText().length() > 0) {
        productService().addComment(product.getId(), comment, new AsyncCommandCallback() {
            @Override/*w  w w .  j  av a2s.  c  om*/
            public void onSuccess(Triple<ProductComment, Product, Date> result) {
                if (null != result.getEntity3())
                    Pages.get().getEventBus().fireEvent(new TopsDateCheckEvent(result.getEntity3()));
                if (null != result.getEntity2()) {
                    Pages.get().getEventBus().fireEvent(new ProductUpdatedEvent(result.getEntity2()));
                }
                Pages.get().getEventBus()
                        .fireEvent(new ProductCommentEvent(result.getEntity2(), result.getEntity1()));
                super.onSuccess(result);
            }
        });
    }
}

From source file:hudson.gwtmarketplace.client.commands.GetProductCategoriesCommand.java

License:Open Source License

public static void refresh() {
    GetProductCategoriesCommand.categories = null;
    service.getCategories(new AsyncCallback<ArrayList<Category>>() {

        @Override//w ww  .  j a  va  2s  . c o  m
        public void onSuccess(ArrayList<Category> result) {
            GetProductCategoriesCommand.categories = result;
            Pages.get().getEventBus().fireEvent(new CategoriesUpdatedEvent(result));
        }

        @Override
        public void onFailure(Throwable caught) {
        }
    });
}

From source file:hudson.gwtmarketplace.client.commands.GetProductDetailsCommand.java

License:Open Source License

@Override
public void execute() {
    Product p = null;//from w  w  w  .  ja va  2s .  c o  m
    boolean successCalled = false;
    if (null != productId)
        p = productIdMap.get(productId);
    else if (null != alias)
        p = productAliasMap.get(alias);
    if (null != p) {
        successCalled = true;
        onSuccess(p);
    }

    if (forViewing) {
        final boolean _successCalled = successCalled;
        // we may need to update the view count so hit the server
        productService().getForViewing(alias, new AsyncCallback<Pair<Product, Date>>() {

            @Override
            public void onSuccess(Pair<Product, Date> result) {
                if (null != result && null != result.getEntity2())
                    Pages.get().getEventBus().fireEvent(new TopsDateCheckEvent(result.getEntity2()));
                cache(result.getEntity1());
                if (!_successCalled)
                    GetProductDetailsCommand.this.onSuccess(result.getEntity1());
            }

            @Override
            public void onFailure(Throwable caught) {
                if (!_successCalled)
                    GetProductDetailsCommand.this.onFailure(caught);
            }
        });
    }
}

From source file:hudson.gwtmarketplace.client.commands.GetTopsCommand.java

License:Open Source License

public void execute() {
    if (null == top10Lists) {
        productService().getTops((null != top10Lists) ? top10Lists.getMaxDate() : null,
                new AsyncCallback<Top10Lists>() {

                    @Override/*from   www.j  ava 2s .com*/
                    public void onSuccess(Top10Lists result) {
                        GetTopsCommand.top10Lists = result;
                        GetTopsCommand.this.onSuccess(result);
                        Pages.get().getEventBus().fireEvent(new TopsUpdatedEvent(result));
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        GetTopsCommand.this.onFailure(caught);
                    }
                });
    } else {
        onSuccess(top10Lists);
    }
}

From source file:hudson.gwtmarketplace.client.commands.SaveProductCommand.java

License:Open Source License

@Override
public void execute() {
    if (null == product.getId()) {
        productService().save(product, new AsyncCommandCallback() {
            @Override//w  ww  .  java  2  s .  c  o m
            public void onSuccess(Product result) {
                Pages.get().getEventBus().fireEvent(new ProductUpdatedEvent(result));
                super.onSuccess(result);
            }
        });
    } else {
        productService().update(product, new AsyncCallback<Void>() {
            @Override
            public void onSuccess(Void result) {
                Pages.get().getEventBus().fireEvent(new ProductUpdatedEvent(product));
                SaveProductCommand.this.onSuccess(product);
                GetProductCategoriesCommand.refresh();
            }

            @Override
            public void onFailure(Throwable caught) {
                SaveProductCommand.this.onFailure(caught);
            }
        });
    }
}