Example usage for com.vaadin.shared.data.sort SortDirection ASCENDING

List of usage examples for com.vaadin.shared.data.sort SortDirection ASCENDING

Introduction

In this page you can find the example usage for com.vaadin.shared.data.sort SortDirection ASCENDING.

Prototype

SortDirection ASCENDING

To view the source code for com.vaadin.shared.data.sort SortDirection ASCENDING.

Click Source Link

Document

Ascending (e.g.

Usage

From source file:$.MyEntityView.java

License:Apache License

public void enter(ViewChangeEvent event) {

        // Apply Vaadin Layout.
        mainLayout = new DefaultVerticalLayout(true, true);

        // Set form options by convention.
        FormOptions fo = new FormOptions();

        // Add a remove button.
        fo.setShowRemoveButton(true);/*  www  .  j  a  va  2 s.  c om*/

        // Add an edit button.
        fo.setShowEditButton(true);

        // This is where the magic happens. The Simple Search layout uses the Dynamo Entity
        // Model Factory to define a Simple Search Screen with sorting, filtering and lazy loading
        // of data.
        SimpleSearchLayout<Integer, MyEntity> movieLayout = new SimpleSearchLayout<Integer, MyEntity>(movieService,
                getModelFactory().getModel(MyEntity.class), QueryType.ID_BASED, fo,
                new com.vaadin.data.sort.SortOrder("id", SortDirection.ASCENDING)) {
        };

        // Some plumbing.
        mainLayout.addComponent(movieLayout);
        setCompositionRoot(mainLayout);
    }

From source file:com.ocs.dynamo.domain.model.impl.ModelBasedFieldFactory.java

License:Apache License

/**
 * Constructs the default sort order of a component based on an Entity Model
 * //from ww  w  . j a v a 2  s.c o m
 * @param entityModel
 *            the entity model
 * @return
 */
private SortOrder[] constructSortOrder(EntityModel<?> entityModel) {
    SortOrder[] sos = new SortOrder[entityModel.getSortOrder().size()];
    int i = 0;
    for (AttributeModel am : entityModel.getSortOrder().keySet()) {
        sos[i++] = new SortOrder(am.getName(),
                entityModel.getSortOrder().get(am) ? SortDirection.ASCENDING : SortDirection.DESCENDING);
    }
    return sos;
}

From source file:com.ocs.dynamo.functional.ui.MultiDomainEditLayout.java

License:Apache License

/**
 * Construct a split layout for a certain domain
 * //from  w  w  w. ja va  2 s . co  m
 * @param domainClass
 *            the class of the domain
 * @param formOptions
 *            the form options
 * @return
 */
@SuppressWarnings("unchecked")
private <T extends Domain> ServiceBasedSplitLayout<Integer, T> constructSplitLayout(Class<T> domainClass,
        FormOptions formOptions) {

    BaseService<Integer, T> baseService = (BaseService<Integer, T>) ServiceLocator
            .getServiceForEntity(domainClass);
    if (baseService != null) {

        ServiceBasedSplitLayout<Integer, T> splitLayout = new ServiceBasedSplitLayout<Integer, T>(baseService,
                getEntityModelFactory().getModel(domainClass), formOptions,
                new SortOrder(Domain.NAME, SortDirection.ASCENDING)) {

            private static final long serialVersionUID = -6504072714662771230L;

            @Override
            protected Filter constructQuickSearchFilter(String value) {
                return new SimpleStringFilter(Domain.NAME, value, true, false);
            }

            @Override
            protected boolean mustEnableButton(Button button, T selectedItem) {
                if (getRemoveButton() == button) {
                    return isDeleteAllowed(getSelectedDomain());
                }
                return true;
            }

            @Override
            protected void postProcessButtonBar(Layout buttonBar) {
                MultiDomainEditLayout.this.postProcessButtonBar(buttonBar);
            }

            @Override
            protected boolean isEditAllowed() {
                return MultiDomainEditLayout.this.isEditAllowed();
            }

        };
        return splitLayout;
    } else {
        throw new OCSRuntimeException(message("ocs.no.service.class.found", domainClass));
    }
}

From source file:com.ocs.dynamo.showcase.movies.HorizontalMoviesSplitView.java

License:Apache License

public void enter(ViewChangeEvent event) {

    // Apply Vaadin Layout.
    mainLayout = new DefaultVerticalLayout(true, true);

    // Set form options by convention.
    FormOptions fo = new FormOptions();
    fo.setOpenInViewMode(true);/*from  w  ww.j av  a 2  s. c om*/

    // Add a remove button.
    fo.setShowRemoveButton(true);

    // Add an edit button.
    fo.setShowEditButton(true);
    fo.setShowQuickSearchField(true);

    // A SplitLayout is a component that displays a search screen and an edit form
    ServiceBasedSplitLayout<Integer, Movie> movieLayout = new ServiceBasedSplitLayout<Integer, Movie>(
            movieService, getModelFactory().getModel(Movie.class), fo,
            new SortOrder("title", SortDirection.ASCENDING)) {

        @Override
        protected Filter constructQuickSearchFilter(String value) {
            // quick search field
            return new SimpleStringFilter("title", value, true, false);
        }
    };

    // Some plumbing.
    mainLayout.addComponent(movieLayout);
    setCompositionRoot(mainLayout);
}

From source file:com.ocs.dynamo.showcase.movies.MoviesView.java

License:Apache License

public void enter(ViewChangeEvent event) {

    // Apply Vaadin Layout.
    mainLayout = new DefaultVerticalLayout(true, true);

    // Set form options by convention.
    FormOptions fo = new FormOptions();

    // Add a remove button.
    fo.setShowRemoveButton(true);//from   ww w  .jav  a 2  s.c o m

    // Add an edit button.
    fo.setShowEditButton(true);

    //fo.setOpenInViewMode(true);

    // This is where the magic happens. The Simple Search layout uses the Dynamo Entity
    // Model Factory to define a Simple Search Screen with sorting, filtering and lazy loading
    // of data.
    SimpleSearchLayout<Integer, Movie> movieLayout = new SimpleSearchLayout<Integer, Movie>(movieService,
            getModelFactory().getModel(Movie.class), QueryType.ID_BASED, fo,
            new com.vaadin.data.sort.SortOrder("id", SortDirection.ASCENDING)) {

        //            @Override
        //            protected void afterModeChanged(boolean viewMode,
        //                    ModelBasedEditForm<Integer, Movie> editForm) {
        //                Notification.show("Mode change", Notification.Type.ERROR_MESSAGE);
        //            }
        //
        //            @Override
        //            protected void afterDetailSelected(ModelBasedEditForm<Integer, Movie> editForm,
        //                    Movie entity) {
        //                editForm.getField("title").setEnabled(false);
        //                Notification.show("Detail selected", Notification.Type.ERROR_MESSAGE);
        //            }
    };

    // Some plumbing.
    mainLayout.addComponent(movieLayout);
    setCompositionRoot(mainLayout);
}

From source file:com.ocs.dynamo.showcase.movies.TabularMoviesView.java

License:Apache License

public void enter(ViewChangeEvent event) {

    // Apply Vaadin Layout.
    mainLayout = new DefaultVerticalLayout(true, true);

    // Set form options by convention.
    FormOptions fo = new FormOptions();
    // fo.setOpenInViewMode(true);

    // Add a remove button.
    fo.setShowRemoveButton(true);/*from w  ww . ja v  a 2 s .  c  om*/

    // Add an edit button.
    fo.setShowEditButton(true);

    // retrieve the country list just once
    allCountries = countryService.findAll();

    // custom entity model for this screen. See the "entitymodel.properties" file for specifics
    EntityModel<Movie> em = getModelFactory().getModel("MoviesTable", Movie.class);

    // A SplitLayout is a component that displays a search screen and an edit form
    TabularEditLayout<Integer, Movie> movieLayout = new TabularEditLayout<Integer, Movie>(movieService, em, fo,
            new SortOrder("title", SortDirection.ASCENDING)) {

        protected Field<?> constructCustomField(EntityModel<Movie> entityModel, AttributeModel attributeModel,
                boolean viewMode, boolean searchMode) {
            if ("country".equals(attributeModel.getName())) {
                EntityComboBox<Integer, Country> cb = new EntityComboBox<Integer, Country>(
                        getEntityModelFactory().getModel(Country.class), attributeModel, allCountries);
                return cb;
            }
            return null;
        }
    };

    movieLayout.setPageLength(25);

    mainLayout.addComponent(movieLayout);
    setCompositionRoot(mainLayout);
}

From source file:com.ocs.dynamo.showcase.movies.VerticalMoviesSplitView.java

License:Apache License

public void enter(ViewChangeEvent event) {

    // Apply Vaadin Layout.
    mainLayout = new DefaultVerticalLayout(true, true);

    // Set form options by convention.
    FormOptions fo = new FormOptions();
    fo.setOpenInViewMode(true);/*from   w ww. j av a 2s . c o  m*/

    // Add a remove button.
    fo.setShowRemoveButton(true);

    // Add an edit button.
    fo.setShowEditButton(true);
    fo.setShowQuickSearchField(true);
    fo.setScreenMode(ScreenMode.VERTICAL);

    // A SplitLayout is a component that displays a search screen and an edit form
    ServiceBasedSplitLayout<Integer, Movie> movieLayout = new ServiceBasedSplitLayout<Integer, Movie>(
            movieService, getModelFactory().getModel(Movie.class), fo,
            new SortOrder("title", SortDirection.ASCENDING)) {

        @Override
        protected Filter constructQuickSearchFilter(String value) {
            // quick search field
            return new SimpleStringFilter("title", value, true, false);
        }
    };
    movieLayout.setPageLength(10);

    // Some plumbing.
    mainLayout.addComponent(movieLayout);
    setCompositionRoot(mainLayout);
}

From source file:com.ocs.dynamo.ui.composite.table.BaseTableWrapper.java

License:Apache License

/**
 * Extracts the sort directions from the sort orders
 *///from   ww w .j  a va 2s  .  c o m
protected boolean[] getSortDirections() {
    boolean[] result = new boolean[getSortOrders().size()];
    for (int i = 0; i < result.length; i++) {
        result[i] = SortDirection.ASCENDING == getSortOrders().get(i).getDirection();
    }
    return result;
}

From source file:com.ocs.dynamo.ui.container.ServiceContainer.java

License:Apache License

public void sort(SortOrder... sortOrder) {
    if (sortOrder != null && sortOrder.length > 0) {
        Object[] pIds = new Object[sortOrder.length];
        boolean[] sos = new boolean[sortOrder.length];
        int i = 0;
        for (SortOrder so : sortOrder) {
            pIds[i] = so.getPropertyId();
            sos[i++] = SortDirection.ASCENDING == so.getDirection();
        }/*  w  w w  . j  a  va 2s.  c o  m*/
        sort(pIds, sos);
    }
}

From source file:com.ocs.dynamo.utils.SortUtil.java

License:Apache License

/**
 * Translates one or more Vaadin sort orders to OCS sort orders
 * //from  www  . jav  a 2  s.c  o  m
 * @param originalOrders
 * @return
 */
public static com.ocs.dynamo.dao.SortOrder[] translate(SortOrder... originalOrders) {
    if (originalOrders != null && originalOrders.length > 0) {
        final com.ocs.dynamo.dao.SortOrder[] orders = new com.ocs.dynamo.dao.SortOrder[originalOrders.length];
        for (int i = 0; i < originalOrders.length; i++) {
            orders[i] = new com.ocs.dynamo.dao.SortOrder(
                    SortDirection.ASCENDING.equals(originalOrders[i].getDirection()) ? Direction.ASC
                            : Direction.DESC,
                    originalOrders[i].getPropertyId().toString());
        }
        return orders;
    }
    return null;
}