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:cimav.client.view.catalogos.departamentos.DeptosUi.java

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

    CellList.Resources cellListResources = GWT.create(ICellListResources.class);
    selectionModel = new SingleSelectionModel<>();
    cellList = new CellList<>(new DeptoCell(selectionModel), cellListResources,
            DeptosProvider.get().getDataProvider());
    cellList.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.ENABLED);
    cellList.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionHandler());
    cellList.setPageSize(400);//from   w w w. ja  va 2s.  c  o  m
    scrollPanel.add(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.
    DeptosProvider.get().addDataDisplay(cellList);

    // Escucha los metodos y las acciones (find_all, update, create, save, reloadById, etc.)
    DeptosProvider.get().addMethodExecutedListener(new ProviderMethodExecutedListener());

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

    addBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            // Deseleccionar
            deseleccionar();

            // enviar nuevo al Bean del Editor
            Departamento nuevo = new Departamento();
            deptosEditorUi.setSelectedBean(nuevo);

        }
    });

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

            DeptosUi.this.filtrar();
        }
    });

    // filtro inicial
    DeptosProvider.get().getDataProvider().setFilter("");

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

From source file:cimav.client.view.catalogos.empleados.EmpleadosUI.java

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

    empleadosBaseProvider = new EmpleadosBaseProvider();

    //CellList.Resources cellListResources = GWT.create(CellList.Resources.class);
    CellList.Resources cellListResources = GWT.create(ICellListResources.class);
    selectionModel = new SingleSelectionModel<>();
    EmpleadoListCell empleadoListCell = new EmpleadoListCell(selectionModel);
    cellList = new CellList<EmpleadoBase>(empleadoListCell, cellListResources,
            empleadosBaseProvider.getDataProvider());
    cellList.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.ENABLED);
    cellList.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionHandler());
    cellList.setPageSize(800); // mximo son 400 empleados. Al mostrarlos todos, no se requiere Pager.
    scrollPanel.add(cellList);// w w  w  .j a  va2  s. c  om

    //                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.
    empleadosBaseProvider.addDataDisplay(cellList);

    // Escucha los metodos y las acciones (find_all, update, create, save, reloadById, etc.)
    empleadosBaseProvider.addMethodExecutedListener(new ProviderMethodExecutedListener());

    reloadBtn.setIconFlip(IconFlip.HORIZONTAL);
    reloadBtn.addClickHandler(new ReloadClickHandler());

    addBtn.addClickHandler(new AddClickHandler());

    searchTxt.addKeyUpHandler(new SearchKeyUpHandler());

    empleadosEditorUI.addActionEditorListener(new EditorActionListener());

    // orden inicial
    orderBy = EmpleadosBaseProvider.ORDER_BY_NAME;
    // filtro inicial
    empleadosBaseProvider.getDataProvider().setFilter("");

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

From source file:cimav.client.view.nomina.NominaListUI.java

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

    empleadosBaseProvider = new EmpleadosBaseProvider();

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

    /* 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.
    empleadosBaseProvider.addDataDisplay(cellList);

    // Escucha los metodos y las acciones (find_all, update, create, save, reloadById, etc.)
    empleadosBaseProvider.addMethodExecutedListener(new ProviderMethodExecutedListener());

    reloadBtn.setIconFlip(IconFlip.HORIZONTAL);
    reloadBtn.addClickHandler(new ReloadClickHandler());

    searchTxt.addKeyUpHandler(new SearchKeyUpHandler());

    // >>        empleadosEditorUI.addActionListener(new EditorActionListener());
    // orden inicial
    orderBy = EmpleadosBaseProvider.ORDER_BY_NAME;
    // filtro inicial
    empleadosBaseProvider.getDataProvider().setFilter("");

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

    btnCalcular.addClickHandler(new CalcularClickHandler());

    toggleSwitch.addValueChangeHandler(new CalcularToggleSwitch());
}

From source file:cimav.visorglass.client.widgets.PanelesLayout.java

License:Apache License

public PanelesLayout(GWTServiceAsync gwtServiceAsync) {
    initWidget(uiBinder.createAndBindUi(this));

    this.gwtServiceAsync = gwtServiceAsync;

    // Crea el Modelo
    arbolModel = new ArbolModel();
    // Crea el node Root
    TreeItem root = new TreeItem(SafeHtmlUtils.fromString("<h2>La Root</h2>"));
    // Cambia  Recursos del Arbol
    CellTree.Resources cellTreeResources = GWT.create(ICellTreeResources.class);
    CellTree.CellTreeMessages cellTreeMsgs = GWT.<CellTree.CellTreeMessages>create(ICellTreeMessages.class);
    // Crea el arbol
    cellArbol = new CellTree(arbolModel, root, cellTreeResources, cellTreeMsgs);
    cellArbol.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.ENABLED);
    // agrega el arbol a su Panel
    //flowPanelArbol.add(cellArbol);
    cellArbol.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
    cellArbol.getElement().getStyle().setTop(10, Style.Unit.PX);
    cellArbol.getElement().getStyle().setLeft(0, Style.Unit.PX);
    cellArbol.getElement().getStyle().setBottom(0, Style.Unit.PX);
    cellArbol.getElement().getStyle().setRight(0, Style.Unit.PX);
    scrollPanelArbol.add(cellArbol);//from   w  w w  .  j  a  v  a2s .  c  o m
    /* Inyectarle style absolute al Abuelo para que funcione el scroll del cellArbol */
    Element divAbue2 = cellArbol.getElement().getParentElement().getParentElement();
    divAbue2.getStyle().setPosition(Style.Position.ABSOLUTE);
    divAbue2.getStyle().setTop(0, Style.Unit.PX);
    divAbue2.getStyle().setLeft(0, Style.Unit.PX);
    divAbue2.getStyle().setBottom(0, Style.Unit.PX);
    divAbue2.getStyle().setRight(0, Style.Unit.PX);

    // Crea CellList de Documentos, sus resources, su Celda, su SelectionModel y su Listener.
    documentoSelectionModel = new SingleSelectionModel<Documento>();
    CellList.Resources cellListResources = GWT.create(ICellListResources.class);
    documentosCellList = new CellList<Documento>(new DocumentoCell(documentoSelectionModel), cellListResources);
    documentosCellList.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.ENABLED);
    documentosCellList.setSelectionModel(documentoSelectionModel);
    documentosCellList.setPageSize(500);
    // listener
    documentoSelectionModel.addSelectionChangeHandler(new DocumentoSelectionHandler());
    // Style absolute
    documentosCellList.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
    documentosCellList.getElement().getStyle().setTop(0, Style.Unit.PX);
    documentosCellList.getElement().getStyle().setLeft(0, Style.Unit.PX);
    documentosCellList.getElement().getStyle().setBottom(0, Style.Unit.PX);
    documentosCellList.getElement().getStyle().setRight(0, Style.Unit.PX);
    // Agregarlo a su panel
    scrollPanelDocumentos.add(documentosCellList);

    /* Inyectarle style absolute al Abuelo para que funcione el scroll del cellList */
    Element divAbue = documentosCellList.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);

    // Listener de los Botones de Paneles
    btnArbol.addClickHandler(new BtnArbolClickHandler());
    btnDocumentos.addClickHandler(new BtnDocumentosClickHandler());
    btnVisor.addClickHandler(new BtnVisorClickHandler());

    // Arega etiquetas flotantes y sus listeners
    Label arbolLabel = new Label("Arbol");
    arbolLabel.setStyleName("jsfiddle_label");
    arbolLabel.addMouseOverHandler(new JSFiddlerMouseOver());
    arbolLabel.addMouseOutHandler(new JSFiddlerMouseOut());
    flowPanelArbol.add(arbolLabel);
    documentosLabel = new Label("Documentos");
    documentosLabel.setStyleName("jsfiddle_label");
    documentosLabel.addMouseOverHandler(new JSFiddlerMouseOver());
    documentosLabel.addMouseOutHandler(new JSFiddlerMouseOut());
    flowPanelDecoratorDocumentos.add(documentosLabel);
    Label visorLabel = new Label("Visor");
    visorLabel.setStyleName("jsfiddle_label");
    visorLabel.addMouseOverHandler(new JSFiddlerMouseOver());
    visorLabel.addMouseOutHandler(new JSFiddlerMouseOut());
    flowPanelDecoratorVisor.add(visorLabel);

    frameDocViewer.addLoadHandler(new FrameLoadHandler());

    reloadIcon = new Icon(IconType.ROTATE_RIGHT);
    reloadIcon.setSize(IconSize.LARGE);
    reloadIcon.setMuted(false);
    reloadIcon.setSpin(false);
    reloadIcon.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
    reloadIcon.getElement().getStyle().setTop(3, Style.Unit.PX);
    reloadIcon.getElement().getStyle().setLeft(3, Style.Unit.PX);
    reloadIcon.getElement().getStyle().setColor("gray");
    reloadIcon.getElement().getStyle().setCursor(Style.Cursor.POINTER);
    reloadIcon.addDomHandler(new ReloadGoogleDocMouseDownHandler(), MouseDownEvent.getType());
    //        flowPanelDecoratorVisor.add(reloadIcon);

    // NOTE Quitar documentos 
    btnDocumentos.setVisible(false);

}

From source file:com.adamantium.company.gwtp.client.application.list.ListView.java

License:Apache License

@Inject
ListView(Binder uiBinder) {
    // Create a CellTable.
    cellTable = new CellTable<CompanyTableInfo>();
    buildColumns(cellTable);/*from w  w  w. java 2  s  .  co m*/
    // Add a selection model to handle user selection.
    final SingleSelectionModel<CompanyTableInfo> selectionModel = new SingleSelectionModel<CompanyTableInfo>();
    cellTable.setSelectionModel(selectionModel);
    //        selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
    //            public void onSelectionChange(SelectionChangeEvent event) {
    //                CompanyTableInfo selected = selectionModel.getSelectedObject();
    //                if (selected != null) {
    //                    Window.alert("You selected: " + selected.getName());
    //                }
    //            }
    //        });
    buildPager();
    initWidget(uiBinder.createAndBindUi(this));
}

From source file:com.agnie.gwt.common.client.widget.SuggestionBox.java

License:Open Source License

public SuggestionBox() {
    container = (HTMLPanel) uiBinder.createAndBindUi(this);
    initWidget(container);/*w ww .j av  a  2s. c  om*/
    list.setVisible(false);

    Label label = new Label(I18.messages.noData());
    list.setEmptyListWidget(label);

    dp.addDataDisplay(list);

    search.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            list.setVisible(true);
        }
    });

    list.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);

    // Add a selection model to handle user selection.
    final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>();
    list.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            String selected = selectionModel.getSelectedObject();
            if (selected != null) {
                Window.alert("You selected: " + selected);
            }
        }
    });

}

From source file:com.codenvy.ide.client.propertiespanel.common.namespace.NameSpaceEditorViewImpl.java

License:Open Source License

private CellTable<NameSpace> createTable(@Nonnull CellTableResources resource) {
    CellTable<NameSpace> table = new CellTable<>(0, resource);

    Column<NameSpace, String> nameSpace = new Column<NameSpace, String>(new TextCell()) {
        @Override//  www  .  j ava2 s . c om
        public String getValue(NameSpace object) {
            return object.toString();
        }
    };

    table.setLoadingIndicator(null);

    table.addColumn(nameSpace);
    table.setColumnWidth(nameSpace, 570, Style.Unit.PX);

    final SingleSelectionModel<NameSpace> selectionModel = new SingleSelectionModel<>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            delegate.onSelectedNameSpace(selectionModel.getSelectedObject());
        }
    });
    table.setSelectionModel(selectionModel);

    return table;
}

From source file:com.codenvy.ide.client.propertiespanel.common.propertyconfig.PropertyConfigViewImpl.java

License:Open Source License

/**
 * Returns cell table entity. Adds column names and values to table. Sets selection model to table.
 *
 * @param localizationConstant/*  ww  w.  j ava 2 s. c o m*/
 *         localization constant which contains special names of element in current table
 */
private CellTable<Property> createTable(@Nonnull final WSO2EditorLocalizationConstant localizationConstant,
        @Nonnull CellTableResources resource) {

    final CellTable<Property> table = new CellTable<>(0, resource);

    final SingleSelectionModel<Property> selectionModel = new SingleSelectionModel<>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            delegate.onSelectedProperty(selectionModel.getSelectedObject());
        }
    });
    table.setSelectionModel(selectionModel);

    TextColumn<Property> name = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            String name = property.getProperty(NAME);

            return name == null ? "" : name;
        }
    };

    TextColumn<Property> expression = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            String value = property.getProperty(VALUE);

            return value == null ? "" : value;
        }
    };

    TextColumn<Property> type = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            ValueType type = property.getProperty(TYPE);

            return type == null ? "" : type.name();
        }
    };

    table.addColumn(name, localizationConstant.columnName());
    table.addColumn(type, localizationConstant.columnType());
    table.addColumn(expression, localizationConstant.columnExpression());

    table.setColumnWidth(name, 210, Style.Unit.PX);
    table.setColumnWidth(type, 120, Style.Unit.PX);
    table.setColumnWidth(expression, 210, Style.Unit.PX);

    table.setLoadingIndicator(null);

    return table;
}

From source file:com.codenvy.ide.client.propertiespanel.endpoints.address.property.PropertyViewImpl.java

License:Open Source License

/** Adds columns names and values to table. Sets selection model to table. */
private CellTable<Property> createTable(@Nonnull CellTableResources resource) {
    CellTable<Property> table = new CellTable<>(0, resource);

    final SingleSelectionModel<Property> selectionModel = new SingleSelectionModel<>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override//w  ww.  j  ava 2 s.  c o m
        public void onSelectionChange(SelectionChangeEvent event) {
            delegate.onPropertySelected(selectionModel.getSelectedObject());
        }
    });
    table.setSelectionModel(selectionModel);

    TextColumn<Property> name = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            return property.getProperty(NAME);
        }
    };

    TextColumn<Property> value = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            if (ValueType.LITERAL.equals(property.getProperty(TYPE))) {
                return property.getProperty(VALUE);
            }

            return property.getProperty(EXPRESSION);
        }
    };

    TextColumn<Property> type = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            ValueType type = property.getProperty(TYPE);

            if (type == null) {
                return "";
            }

            return type.name();
        }
    };

    TextColumn<Property> scope = new TextColumn<Property>() {
        @Override
        public String getValue(Property property) {
            Property.Scope scope = property.getProperty(SCOPE);

            if (scope == null) {
                return "";
            }

            return scope.getValue();
        }
    };

    table.addColumn(name, locale.columnName());
    table.addColumn(value, locale.columnValue());
    table.addColumn(type, locale.columnType());
    table.addColumn(scope, locale.columnScope());

    table.setColumnWidth(name, 150, Style.Unit.PX);
    table.setColumnWidth(value, 150, Style.Unit.PX);
    table.setColumnWidth(type, 60, Style.Unit.PX);
    table.setColumnWidth(scope, 100, Style.Unit.PX);

    table.setLoadingIndicator(null);

    return table;
}

From source file:com.codenvy.ide.client.propertiespanel.mediators.arguments.ArgumentsConfigViewImpl.java

License:Open Source License

private CellTable<Arg> createTable(@Nonnull final WSO2EditorLocalizationConstant localizationConstant,
        @Nonnull CellTableResources resource) {

    final CellTable<Arg> table = new CellTable<>(0, resource);

    final SingleSelectionModel<Arg> selectionModel = new SingleSelectionModel<>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override/*from   w ww  .java  2  s  .c  o m*/
        public void onSelectionChange(SelectionChangeEvent event) {
            delegate.onSelectedArg(selectionModel.getSelectedObject());
        }
    });
    table.setSelectionModel(selectionModel);

    TextColumn<Arg> value = new TextColumn<Arg>() {
        @Override
        public String getValue(Arg object) {
            return object.getProperty(ARG_VALUE);
        }
    };

    TextColumn<Arg> type = new TextColumn<Arg>() {
        @Override
        public String getValue(Arg arg) {
            ArgType argType = arg.getProperty(ARG_TYPE);

            return argType == null ? "" : argType.getValue();
        }
    };

    TextColumn<Arg> evaluator = new TextColumn<Arg>() {
        @Override
        public String getValue(Arg arg) {
            Evaluator evaluator = arg.getProperty(ARG_EVALUATOR);

            return evaluator == null ? "" : evaluator.getValue();
        }
    };

    table.addColumn(type, localizationConstant.columnType());
    table.addColumn(value, localizationConstant.columnValue());
    table.addColumn(evaluator, localizationConstant.columnEvaluator());

    table.setColumnWidth(type, 120, PX);
    table.setColumnWidth(value, 210, PX);
    table.setColumnWidth(evaluator, 120, PX);

    table.setLoadingIndicator(null);

    return table;
}