@Override public void init(QuickNewJobPresenter p) { this.presenter = p; newParametersButton.setText(constants.Add_Parameter()); createButton.setText(constants.Create()); jobNameLabel.setText(constants.Name()); jobDueLabel.setText(constants.Due_On()); jobTypeLabel.setText(constants.Type()); dataTriesLabel.setText(constants.Retries()); myParametersGrid.setHeight("200px"); // Set the message to display when the table is empty. myParametersGrid.setEmptyTableWidget(new Label(constants.No_Parameters_added_yet())); initGridColumns(); long now = System.currentTimeMillis(); jobDueDate.setEnabled(true); jobDueDate.setValue(now); jobDueDateTime.setValue(UTCDateBox.date2utc(new Date())); }
private void setupSessionDataGrid() { sessionsDataGrid = new DataGrid<SessionDataDto>(); sessionsDataGrid.setPageSize(15); sessionsDataGrid.setEmptyTableWidget(new Label("No Sessions")); // Add a selection model so we can select cells. final SelectionModel<SessionDataDto> selectionModel = new MultiSelectionModel<SessionDataDto>( new ProvidesKey<SessionDataDto>() { @Override public Object getKey(SessionDataDto item) { return item.getSessionId(); } }); sessionsDataGrid.setSelectionModel( selectionModel, DefaultSelectionEventManager.<SessionDataDto>createCheckboxManager()); // Checkbox column. This table will uses a checkbox column for selection. // Alternatively, you can call dataGrid.setSelectionEnabled(true) to enable mouse selection. Column<SessionDataDto, Boolean> checkColumn = new Column<SessionDataDto, Boolean>(new CheckboxCell(true, false)) { @Override public Boolean getValue(SessionDataDto object) { // Get the value from the selection model. return selectionModel.isSelected(object); } }; sessionsDataGrid.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); sessionsDataGrid.setColumnWidth(checkColumn, 40, Style.Unit.PX); sessionsDataGrid.addColumn( new TextColumn<SessionDataDto>() { @Override public String getValue(SessionDataDto object) { return object.getName(); } }, "Name"); sessionsDataGrid.addColumn( new TextColumn<SessionDataDto>() { @Override public String getValue(SessionDataDto object) { return object.getStartDate(); } }, "Start Date"); sessionsDataGrid.addColumn( new TextColumn<SessionDataDto>() { @Override public String getValue(SessionDataDto object) { return object.getEndDate(); } }, "End Date"); sessionDataProvider.addDataDisplay(sessionsDataGrid); }
public OrganismPanel() { initWidget(ourUiBinder.createAndBindUi(this)); loadingDialog = new LoadingDialog("Processing ...", null, false); TextColumn<OrganismInfo> organismNameColumn = new TextColumn<OrganismInfo>() { @Override public String getValue(OrganismInfo organism) { return organism.getName(); } }; Column<OrganismInfo, Number> annotationsNameColumn = new Column<OrganismInfo, Number>(new NumberCell()) { @Override public Integer getValue(OrganismInfo object) { return object.getNumFeatures(); } }; Column<OrganismInfo, Number> sequenceColumn = new Column<OrganismInfo, Number>(new NumberCell()) { @Override public Integer getValue(OrganismInfo object) { return object.getNumSequences(); } }; sequenceColumn.setSortable(true); organismNameColumn.setSortable(true); annotationsNameColumn.setSortable(true); Annotator.eventBus.addHandler( OrganismChangeEvent.TYPE, new OrganismChangeEventHandler() { @Override public void onOrganismChanged(OrganismChangeEvent organismChangeEvent) { organismInfoList.clear(); organismInfoList.addAll(MainPanel.getInstance().getOrganismInfoList()); } }); dataGrid.setLoadingIndicator(new HTML("Calculating Annotations ... ")); dataGrid.addColumn(organismNameColumn, "Name"); dataGrid.addColumn(annotationsNameColumn, "Annotations"); dataGrid.addColumn(sequenceColumn, "Ref Sequences"); dataGrid.setEmptyTableWidget( new Label("No organisms available. Add new organisms using the form field.")); singleSelectionModel.addSelectionChangeHandler( new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { if (!creatingNewOrganism) { loadOrganismInfo(); changeButtonSelection(); } else { creatingNewOrganism = false; } } }); dataGrid.setSelectionModel(singleSelectionModel); dataProvider.addDataDisplay(dataGrid); dataGrid.addDomHandler( new DoubleClickHandler() { @Override public void onDoubleClick(DoubleClickEvent event) { if (singleSelectionModel.getSelectedObject() != null) { String orgId = singleSelectionModel.getSelectedObject().getId(); if (!MainPanel.getInstance().getCurrentOrganism().getId().equals(orgId)) { OrganismRestService.switchOrganismById(orgId); } } } }, DoubleClickEvent.getType()); List<OrganismInfo> trackInfoList = dataProvider.getList(); ColumnSortEvent.ListHandler<OrganismInfo> sortHandler = new ColumnSortEvent.ListHandler<OrganismInfo>(trackInfoList); dataGrid.addColumnSortHandler(sortHandler); sortHandler.setComparator( organismNameColumn, new Comparator<OrganismInfo>() { @Override public int compare(OrganismInfo o1, OrganismInfo o2) { return o1.getName().compareTo(o2.getName()); } }); sortHandler.setComparator( annotationsNameColumn, new Comparator<OrganismInfo>() { @Override public int compare(OrganismInfo o1, OrganismInfo o2) { return o1.getNumFeatures() - o2.getNumFeatures(); } }); sortHandler.setComparator( sequenceColumn, new Comparator<OrganismInfo>() { @Override public int compare(OrganismInfo o1, OrganismInfo o2) { return o1.getNumSequences() - o2.getNumSequences(); } }); }
public SupplyLayout() { this.res = GWT.create(SupplyResources.class); res.style().ensureInjected(); initWidget(uiBinder.createAndBindUi(this)); final ListDataProvider<Supply> dataProvider = new ListDataProvider<Supply>(); dataGrid.setMinimumTableWidth(150, Unit.PX); dataGrid.setWidth("100%"); dataGrid.setHeight("450px"); dataGrid.setAutoHeaderRefreshDisabled(true); dataGrid.setEmptyTableWidget(new Label("Нет данных")); ListHandler<Supply> sortHandler = new ListHandler<Supply>(dataProvider.getList()); dataGrid.addColumnSortHandler(sortHandler); SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true); pager.setDisplay(dataGrid); pager.setPageSize(10); pager.setPageStart(0); panel.add(pager); final SelectionModel<Supply> selectionModel = new MultiSelectionModel<Supply>(); dataGrid.setSelectionModel( selectionModel, DefaultSelectionEventManager.<Supply>createDefaultManager()); initTableColumns(selectionModel, sortHandler); // Верхняя панелька для поиск searchFlexTable = new FlexTable(); cellFormatter = searchFlexTable.getFlexCellFormatter(); searchFlexTable.setWidth("80%"); searchFlexTable.setCellSpacing(5); searchFlexTable.setCellPadding(1); Label idLabel = new Label("Номер"); final TextBox idTBox = new TextBox(); searchFlexTable.setWidget(0, 0, idLabel); searchFlexTable.setWidget(0, 1, idTBox); Label addressLabel = new Label("Адрес"); final TextBox addressTBox = new TextBox(); searchFlexTable.setWidget(1, 0, addressLabel); searchFlexTable.setWidget(1, 1, addressTBox); // Create a basic date picker DatePicker datePicker = new DatePicker(); final Label text = new Label(); // Set the value in the text box when the user selects a date datePicker.addValueChangeHandler( new ValueChangeHandler<Date>() { public void onValueChange(ValueChangeEvent<Date> event) { Date date = event.getValue(); String dateString = DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM).format(date); text.setText(dateString); } }); // Set the default value // datePicker.setValue(new Date(), true); // Create a DateBox DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("yyyy-MM-dd"); final DateBox dateBox = new DateBox(); dateBox.setFormat(new DateBox.DefaultFormat(dateTimeFormat)); Label dateLabel = new Label("Дата"); searchFlexTable.setWidget(2, 0, dateLabel); searchFlexTable.setWidget(2, 1, dateBox); Label typeLabel = new Label("Тип"); final ListBox typeLB = new ListBox(); typeLB.addItem(""); typeLB.addItem("В филиал"); typeLB.addItem("На склад"); searchFlexTable.setWidget(3, 0, typeLabel); searchFlexTable.setWidget(3, 1, typeLB); Label statusLabel = new Label("Статус"); final ListBox statusLB = new ListBox(); statusLB.addItem(""); for (String type : StatusDict.getAsStringList()) { statusLB.addItem(type); } searchFlexTable.setWidget(4, 0, statusLabel); searchFlexTable.setWidget(4, 1, statusLB); cellFormatter.setRowSpan(5, 0, 2); Button search = new Button("Найти"); searchFlexTable.setWidget(5, 0, search); search.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { // формируем карту с where statement: Map<String, String> whereMap = new HashMap<String, String>(); if (idTBox.getText() != null && !"".equals(idTBox.getText())) whereMap.put("supid", idTBox.getText()); if (addressTBox.getText() != null && !"".equals(addressTBox.getText())) whereMap.put("address", addressTBox.getText()); if (dateBox.getTextBox().getText() != null && !"".equals(dateBox.getTextBox().getText())) whereMap.put("date", dateBox.getTextBox().getText()); if (typeLB.getSelectedIndex() != 0) { if (typeLB.getSelectedIndex() == 1) whereMap.put("DeliveryDirection", "1"); if (typeLB.getSelectedIndex() == 2) whereMap.put("DeliveryDirection", "0"); } if (statusLB.getSelectedIndex() != 0) whereMap.put("SupStatusID", Integer.toString(statusLB.getSelectedIndex())); supplyService.getByConditions( whereMap, new AsyncCallback<List<Supply>>() { @Override public void onSuccess(List<Supply> result) { if (result != null) { dataProvider.getList().clear(); dataProvider.getList().addAll(result); dataProvider.refresh(); } } @Override public void onFailure(Throwable caught) { Window.alert("Ошибка"); } }); } }); additionalPanel.add(searchFlexTable); // ///////////////////////////////////////////////////// supplyService.getLast( 10, new AsyncCallback<List<Supply>>() { @Override public void onSuccess(List<Supply> result) { if (result != null) { dataProvider.getList().addAll(result); dataProvider.addDataDisplay(dataGrid); dataProvider.refresh(); } } @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub } }); }