Example usage for com.google.gwt.view.client SingleSelectionModel SingleSelectionModel

List of usage examples for com.google.gwt.view.client SingleSelectionModel SingleSelectionModel

Introduction

In this page you can find the example usage for com.google.gwt.view.client SingleSelectionModel SingleSelectionModel.

Prototype

public SingleSelectionModel() 

Source Link

Document

Constructs a SingleSelectionModel without a key provider.

Usage

From source file:n3phele.client.view.ServiceListView.java

License:Open Source License

public ServiceListView() {
    super(new MenuItem(N3phele.n3pheleResource.serviceIcon(), "Service List", null),
            new MenuItem(N3phele.n3pheleResource.serviceIcon(), "create a new service", "service:null"));

    HorizontalPanel heading = new HorizontalPanel();
    heading.setWidth("500px");
    heading.setStyleName(N3phele.n3pheleResource.css().sectionPanelHeader());
    add(heading);//from  w  w  w .j a  v a 2 s.c  o m
    heading.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    SimplePager simplePager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    heading.add(simplePager);
    heading.setCellHorizontalAlignment(simplePager, HorizontalPanel.ALIGN_CENTER);

    this.cellTable = new ActivityStatusList();
    this.cellTable.setWidth("100%");
    TextColumn<CloudProcessSummary> narrative = new TextColumn<CloudProcessSummary>() {

        @Override
        public String getValue(CloudProcessSummary process) {
            String result = "";
            List<Narrative> narrative = process.getNarrative();
            if (narrative != null && narrative.size() > 0) {
                result = narrative.get(narrative.size() - 1).getText();
            }

            return result;
        }
    };
    this.cellTable.addColumn(narrative);
    this.cellTable.setColumnWidth(narrative, "55%");
    Column<CloudProcessSummary, CloudProcessSummary> cancelColumn = new Column<CloudProcessSummary, CloudProcessSummary>(
            new CancelButtonCell<CloudProcessSummary>(new Delegate<CloudProcessSummary>() {

                @Override
                public void execute(CloudProcessSummary value) {
                    if (value != null) {
                        cellTable.getSelectionModel().setSelected(value, false);
                        getDialog(value).show();
                    }
                }
            }, "cancel service")) {
        @Override
        public CloudProcessSummary getValue(CloudProcessSummary object) {
            String status = object.getState();
            if (status == null || status.equalsIgnoreCase("COMPLETE") || status.equalsIgnoreCase("FAILED")
                    || status.equalsIgnoreCase("CANCELLED")) {
                return null;
            }
            return object;
        }
    };
    cellTable.addColumn(cancelColumn);
    cellTable.setColumnWidth(cancelColumn, "26px");
    this.add(cellTable);
    cellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    final SingleSelectionModel<CloudProcessSummary> selectionModel = new SingleSelectionModel<CloudProcessSummary>();
    cellTable.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            CloudProcessSummary selected = selectionModel.getSelectedObject();
            if (selected != null) {
                if (presenter != null) {
                    presenter.onSelect(selected);
                    // selectionModel.setSelected(selected, false);
                }

            }
        }
    });

    /*
     * Add Table paging
     */
    simplePager.setDisplay(cellTable);
    simplePager.setPageSize(PAGESIZE);
    cellTable.addRangeChangeHandler(new RangeChangeEvent.Handler() {

        /* (non-Javadoc)
         * @see com.google.gwt.view.client.RangeChangeEvent.Handler#onRangeChange(com.google.gwt.view.client.RangeChangeEvent)
         */
        @Override
        public void onRangeChange(RangeChangeEvent event) {
            Range range = cellTable.getVisibleRange();
            int start = range.getStart();
            GWT.log("Fetch " + start);
            presenter.refresh(start);
        }

    });
    this.add(cellTable);

}

From source file:n3phele.client.widgets.MainMenuTreeViewModel.java

License:Open Source License

public MainMenuTreeViewModel(List<MenuItem> list) {
    this.selectionModel = new SingleSelectionModel<MenuItem>();
    this.dataProvider = new ListDataProvider<MenuItem>(list);
    this.selectionModel.addSelectionChangeHandler(new Handler() {

        @Override/*from ww w  . ja  v  a 2  s.  com*/
        public void onSelectionChange(SelectionChangeEvent event) {
            MenuItem item = MainMenuTreeViewModel.this.selectionModel.getSelectedObject();
            if (item != null && item.getPlaceToken() != null) {
                History.newItem(item.getPlaceToken());
            }
        }
    });

}

From source file:net.scran24.user.client.survey.FoodLookupList.java

public FoodLookupList(List<EncodedFood> choices, final SelectionHandler handler) {
    EncodedFoodCell cell = new EncodedFoodCell();

    List<EncodedFood> data = new ArrayList<EncodedFood>();

    CellList<EncodedFood> list = new CellList<EncodedFood>(cell, GWT.<R>create(R.class));
    list.setRowData(data);/*  w ww  .j a  v  a  2 s .com*/
    final SingleSelectionModel<EncodedFood> selectionModel = new SingleSelectionModel<EncodedFood>();
    selectionModel.addSelectionChangeHandler(new Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            handler.selectionChanged(selectionModel.getSelectedObject());
        }
    });
    list.setSelectionModel(selectionModel);

    add(list);
}

From source file:org.apache.hupa.client.ui._CenterContactPanel.java

License:Apache License

private CellList<String> createTabList() {
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x2_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x10x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x10x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x0");
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x00x10x00x10x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x00x10x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x00x10x00x00x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x00x10x00x00x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x00x10x00x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x00x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x00x00x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x00x00x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x00x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x00x10x00x0");
    CellList<String> cellList = new CellList<String>(new SpanCell());
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x10x0");
    cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x20x10x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x20x10x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x20x2_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x20x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x2_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x20x20x00x00x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x20x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x20x20x00x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x20x20x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x20x20x00x00x0");
    final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>();
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x3_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x30x0");
    cellList.setSelectionModel(selectionModel);
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x4");
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            InstrumentationLoggerProvider.get().instrument(
                    "org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a24198_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a241980x2_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a241980x20x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a241980x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a241980x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a241980x3");
            InstrumentationLoggerProvider.get().instrument(
                    "org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a241980x30x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a241980x30x00x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a241980x30x00x10x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a241980x30x00x0");
            String selected = selectionModel.getSelectedObject();
            if (selected != null) {
                InstrumentationLoggerProvider.get().instrument(
                        "org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a241980x30x10x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a241980x30x1_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x40x00x00x112a241980x30x10x0");
                // Window.alert("You selected: " + selected);
            }// w w w .ja v a2  s.c om
        }
    });
    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x50x00x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x50x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x5");
    cellList.setRowCount(TABS.size(), true);

    InstrumentationLoggerProvider.get().instrument(
            "org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x60x0_____org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x6");
    // Push the data into the widget.
    cellList.setRowData(0, TABS);
    InstrumentationLoggerProvider.get()
            .instrument("org_apache_hupa_client_ui__CenterContactPanel_java0x0ed5d27e41436900a0x20x7");
    return cellList;
}

From source file:org.cimav.client.ui.empleados.EmpleadosUI.java

public EmpleadosUI() {
    initWidget(uiBinder.createAndBindUi(this));

    //CellList.Resources cellListResources = GWT.create(CellList.Resources.class);
    CellList.Resources cellListResources = GWT.create(ICellListResources.class);
    selectionModel = new SingleSelectionModel<>();
    cellList = new CellList<>(new EmpleadoCell(selectionModel), cellListResources,
            EmpleadosProvider.get().getDataProvider());
    cellList.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.ENABLED);
    cellList.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionHandler());
    cellList.setPageSize(600); // mximo son 400 empleados. Al mostrarlos todos, no se requiere Pager.
    scrollPanel.add(cellList);/*from  w w  w .  ja  v a  2 s.  c o m*/

    //                SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    //        pager = new SimplePager(SimplePager.TextLocation.CENTER, pagerResources, false, 0, true);
    //        pager.setDisplay(dataGrid);
    /* Inyectarle style absolute al Abuelo para que funcione el scroll del cellList */
    Element divAbue = cellList.getElement().getParentElement().getParentElement();
    divAbue.getStyle().setPosition(Style.Position.ABSOLUTE);
    divAbue.getStyle().setTop(0, Style.Unit.PX);
    divAbue.getStyle().setLeft(0, Style.Unit.PX);
    divAbue.getStyle().setBottom(0, Style.Unit.PX);
    divAbue.getStyle().setRight(0, Style.Unit.PX);

    // Add the CellList to the adapter in the database.
    EmpleadosProvider.get().addDataDisplay(cellList);

    EmpleadosProvider.get().addMethodExecutedListener(new ProviderMethodExecutedListener());

    reloadBtn.setIconFlip(IconFlip.HORIZONTAL);
    reloadBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            reloadAll();
        }
    });

    searchTxt.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent event) {

            EmpleadosUI.this.filtrar();
        }
    });

    // de inicio, el Editor no tiene seleccionando y por tanto no es visible
    this.showEditor(false);

    // orden inicial
    orderBy = EmpleadosProvider.ORDER_BY_NAME;
    // filtro inicial
    EmpleadosProvider.get().getDataProvider().setFilter("");

    /* Al arrancar, cargar a todos los empleados */
    reloadAll();
}

From source file:org.cloudcoder.app.client.view.CoursesListView.java

License:Open Source License

@Override
public void activate(final Session session, SubscriptionRegistrar subscriptionRegistrar) {
    this.session = session;
    this.session.subscribe(Session.Event.ADDED_OBJECT, this, subscriptionRegistrar);

    final SingleSelectionModel<CourseAndCourseRegistration> selectionModel = new SingleSelectionModel<CourseAndCourseRegistration>();
    selectionModel.addSelectionChangeHandler(new Handler() {

        @Override// w ww  .  java2  s.c om
        public void onSelectionChange(SelectionChangeEvent event) {
            selected = selectionModel.getSelectedObject();
            session.add(new CourseListSelection(selected));
        }

    });

    grid.setSelectionModel(selectionModel);

    loadCourses();
}

From source file:org.cloudcoder.app.client.view.ImportCourseSelectionView.java

License:Open Source License

/**
 * Constructor.//ww w .  ja va 2  s .com
 * 
 * @param session the {@link Session}
 */
public ImportCourseSelectionView(Session session) {
    this.session = session;
    this.instructorCourseList = new ArrayList<CourseAndCourseRegistration>();

    populateInstructorCourseList();

    instructorCourseGrid = new DataGrid<CourseAndCourseRegistration>();
    instructorCourseGrid.addColumn(new TermAndYearColumn(), "Term");
    instructorCourseGrid.addColumn(new CourseNameColumn(), "Course");

    instructorCourseGrid.setRowData(0, instructorCourseList);

    selectionModel = new SingleSelectionModel<CourseAndCourseRegistration>();
    instructorCourseGrid.setSelectionModel(selectionModel);

    initWidget(instructorCourseGrid);
}

From source file:org.cloudcoder.app.client.view.ProblemListView2.java

License:Open Source License

public void activate(final Session session, final SubscriptionRegistrar subscriptionRegistrar) {
    this.session = session;

    // Subscribe to session ADDED_OBJECT events (so we will see when a course is selected)
    session.subscribe(Session.Event.ADDED_OBJECT, this, subscriptionRegistrar);

    // When a problem is selected, add it to the session
    final SingleSelectionModel<ProblemAndSubmissionReceipt> selectionModel = new SingleSelectionModel<ProblemAndSubmissionReceipt>();
    cellTable.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override/*from w  ww  .  j  a  v a  2 s .  c o  m*/
        public void onSelectionChange(SelectionChangeEvent event) {
            ProblemAndSubmissionReceipt selected = selectionModel.getSelectedObject();
            if (selected != null) {
                // Add the problem to the Session
                session.add(selected.getProblem());
            }
        }
    });

    // If there is already a Course selected, load its problems.
    // Otherwise, if there are problems already in the session, display them.
    CourseSelection courseSelection = session.get(CourseSelection.class);
    ProblemAndSubmissionReceipt[] problemList = session.get(ProblemAndSubmissionReceipt[].class);
    if (courseSelection != null) {
        loadProblemsForCourse(courseSelection);
    } else if (problemList != null) {
        displayLoadedProblems(problemList);
    }
}

From source file:org.cloudcoder.app.client.view.UserAccountView.java

License:Open Source License

@Override
public void activate(final Session session, SubscriptionRegistrar subscriptionRegistrar) {
    this.session = session;

    // Set selection model.
    // When a User record is selected, it will be added to the Session.
    final SingleSelectionModel<User> selectionModel = new SingleSelectionModel<User>();
    selectionModel.addSelectionChangeHandler(new Handler() {
        @Override//from  ww  w.  j  ava  2 s . c o m
        public void onSelectionChange(SelectionChangeEvent event) {
            User selected = selectionModel.getSelectedObject();
            if (selected != null) {
                session.add(selected);
            }
        }
    });
    grid.setSelectionModel(selectionModel);

    // If the session contains a list of Users, display them.
    // Otherwise, initiate loading of users for this course.
    User[] userList = session.get(User[].class);

    //ProblemAndSubmissionReceipt[] problemAndSubmissionReceiptList = session.get(ProblemAndSubmissionReceipt[].class);
    if (userList != null) {
        displayUser(userList);
    } else {
        loadUser(session);
    }

}

From source file:org.cloudcoder.app.client.view.UserAdminUsersListView.java

License:Open Source License

@Override
public void activate(final Session session, SubscriptionRegistrar subscriptionRegistrar) {
    // Get selected section
    this.section = session.get(Section.class);

    this.session = session;
    this.session.subscribe(Session.Event.ADDED_OBJECT, this, subscriptionRegistrar);
    //this.loggedUser=this.session.get(User.class);
    // Set selection model.
    // When a User record is selected, it will be added to the Session.
    final SingleSelectionModel<User> selectionModel = new SingleSelectionModel<User>();
    selectionModel.addSelectionChangeHandler(new Handler() {
        @Override//from  w ww  .j ava2s  .c om
        public void onSelectionChange(SelectionChangeEvent event) {
            selected = selectionModel.getSelectedObject();
            //session.add(loggedUser);
            session.add(new UserSelection(selected));
        }
    });
    grid.setSelectionModel(selectionModel);

    // Load users for course/section
    loadUsers();

}