select instead of combobox where appropriate. Use vaadin numberfield instead of custom one
This commit is contained in:
parent
5c00a3cfbe
commit
0246bd6b27
10 changed files with 103 additions and 131 deletions
|
@ -28,6 +28,7 @@ import javax.persistence.GeneratedValue;
|
|||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author lukas
|
||||
|
@ -79,4 +80,21 @@ public class Version implements Comparable<Version>{
|
|||
public int compareTo(@NonNull Version o) {
|
||||
return Integer.compare(code, o.code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Version version = (Version) o;
|
||||
return id == version.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@ import com.vaadin.flow.component.HasSize;
|
|||
import com.vaadin.flow.component.HasStyle;
|
||||
import com.vaadin.flow.component.HasValue;
|
||||
import com.vaadin.flow.component.checkbox.Checkbox;
|
||||
import com.vaadin.flow.component.combobox.ComboBox;
|
||||
import com.vaadin.flow.component.formlayout.FormLayout;
|
||||
import com.vaadin.flow.component.orderedlayout.FlexComponent;
|
||||
import com.vaadin.flow.component.select.Select;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
|
@ -96,13 +96,11 @@ class Property<F, C extends Component & HasValue<?, F> & HasEnabled & HasSize &
|
|||
|
||||
Property<?, ?, ?> createStringProperty(App app, ComparableExpressionBase<String> stringExpression, String filterTextId, String chartTitleId) {
|
||||
List<String> list = dataService.getFromReports(app, expression, stringExpression);
|
||||
ComboBox<String> comboBox = new ComboBox<>(null, list);
|
||||
comboBox.setAllowCustomValue(false);
|
||||
comboBox.setRequired(true);
|
||||
Select<String> select = new Select<>(list.toArray(new String[0]));
|
||||
if(!list.isEmpty()) {
|
||||
comboBox.setValue(list.get(0));
|
||||
select.setValue(list.get(0));
|
||||
}
|
||||
return new Property<>(app, comboBox, stringExpression::eq, new PieChart(chartTitleId), dataService, stringExpression, filterTextId);
|
||||
return new Property<>(app, select, stringExpression::eq, new PieChart(chartTitleId), dataService, stringExpression, filterTextId);
|
||||
}
|
||||
|
||||
Property<?, ?, ?> createAgeProperty(App app, DateTimePath<ZonedDateTime> dateTimeExpression, String filterTextId, String chartTitleId) {
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2018 Lukas Morawietz (https://github.com/F43nd1r)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.faendir.acra.ui.component;
|
||||
|
||||
import com.vaadin.flow.component.AbstractSinglePropertyField;
|
||||
import com.vaadin.flow.component.Focusable;
|
||||
import com.vaadin.flow.component.PropertyDescriptor;
|
||||
import com.vaadin.flow.component.PropertyDescriptors;
|
||||
import com.vaadin.flow.component.Tag;
|
||||
|
||||
/**
|
||||
* @author lukas
|
||||
* @since 29.11.18
|
||||
*/
|
||||
@Tag(Tag.INPUT)
|
||||
public abstract class AbstractNumberInput extends AbstractSinglePropertyField<AbstractNumberInput, Double> implements Focusable<AbstractNumberInput>, HasSize, HasStyle {
|
||||
private static final PropertyDescriptor<Double, Double> MIN_DESCRIPTOR = PropertyDescriptors.propertyWithDefault("min", 0d);
|
||||
private static final PropertyDescriptor<Double, Double> MAX_DESCRIPTOR = PropertyDescriptors.propertyWithDefault("max", 100d);
|
||||
private static final PropertyDescriptor<Double, Double> STEP_DESCRIPTOR = PropertyDescriptors.propertyWithDefault("step", 1d);
|
||||
private static final PropertyDescriptor<String, String> TYPE_DESCRIPTOR = PropertyDescriptors.attributeWithDefault("type", "text");
|
||||
public AbstractNumberInput() {
|
||||
super("value", 0d, false);
|
||||
setSynchronizedEvent("change");
|
||||
}
|
||||
|
||||
public void setMin(double min) {
|
||||
set(MIN_DESCRIPTOR, min);
|
||||
}
|
||||
|
||||
public double getMin() {
|
||||
return get(MIN_DESCRIPTOR);
|
||||
}
|
||||
|
||||
public void setMax(double max) {
|
||||
set(MAX_DESCRIPTOR, max);
|
||||
}
|
||||
|
||||
public double getMax() {
|
||||
return get(MAX_DESCRIPTOR);
|
||||
}
|
||||
|
||||
public void setStep(double step) {
|
||||
set(STEP_DESCRIPTOR, step);
|
||||
}
|
||||
|
||||
public double getStep() {
|
||||
return get(STEP_DESCRIPTOR);
|
||||
}
|
||||
public void setType(String type) {
|
||||
set(TYPE_DESCRIPTOR, type);
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return get(TYPE_DESCRIPTOR);
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2018 Lukas Morawietz (https://github.com/F43nd1r)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.faendir.acra.ui.component;
|
||||
|
||||
/**
|
||||
* @author lukas
|
||||
* @since 29.11.18
|
||||
*/
|
||||
public class NumberInput extends AbstractNumberInput {
|
||||
public NumberInput() {
|
||||
setType("number");
|
||||
}
|
||||
|
||||
public NumberInput(double value) {
|
||||
this();
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
public NumberInput(double value, double min, double max) {
|
||||
this();
|
||||
setValue(value);
|
||||
setMin(min);
|
||||
setMax(max);
|
||||
}
|
||||
}
|
|
@ -16,19 +16,66 @@
|
|||
|
||||
package com.faendir.acra.ui.component;
|
||||
|
||||
import com.vaadin.flow.component.AbstractSinglePropertyField;
|
||||
import com.vaadin.flow.component.Focusable;
|
||||
import com.vaadin.flow.component.PropertyDescriptor;
|
||||
import com.vaadin.flow.component.PropertyDescriptors;
|
||||
import com.vaadin.flow.component.Tag;
|
||||
|
||||
/**
|
||||
* @author lukas
|
||||
* @since 29.11.18
|
||||
*/
|
||||
public class RangeInput extends AbstractNumberInput {
|
||||
@Tag(Tag.INPUT)
|
||||
public class RangeInput extends AbstractSinglePropertyField<RangeInput, Double> implements Focusable<RangeInput>, HasSize, HasStyle {
|
||||
private static final PropertyDescriptor<Double, Double> MIN_DESCRIPTOR = PropertyDescriptors.propertyWithDefault("min", 0d);
|
||||
private static final PropertyDescriptor<Double, Double> MAX_DESCRIPTOR = PropertyDescriptors.propertyWithDefault("max", 100d);
|
||||
private static final PropertyDescriptor<Double, Double> STEP_DESCRIPTOR = PropertyDescriptors.propertyWithDefault("step", 1d);
|
||||
private static final PropertyDescriptor<String, String> TYPE_DESCRIPTOR = PropertyDescriptors.attributeWithDefault("type", "text");
|
||||
|
||||
public RangeInput() {
|
||||
super("value", 0d, false);
|
||||
setSynchronizedEvent("change");
|
||||
setType("range");
|
||||
}
|
||||
|
||||
public RangeInput(double min, double max, double defaultValue) {
|
||||
this();
|
||||
setSynchronizedEvent("change");
|
||||
setMin(min);
|
||||
setMax(max);
|
||||
setValue(defaultValue);
|
||||
}
|
||||
|
||||
public void setMin(double min) {
|
||||
set(MIN_DESCRIPTOR, min);
|
||||
}
|
||||
|
||||
public double getMin() {
|
||||
return get(MIN_DESCRIPTOR);
|
||||
}
|
||||
|
||||
public void setMax(double max) {
|
||||
set(MAX_DESCRIPTOR, max);
|
||||
}
|
||||
|
||||
public double getMax() {
|
||||
return get(MAX_DESCRIPTOR);
|
||||
}
|
||||
|
||||
public void setStep(double step) {
|
||||
set(STEP_DESCRIPTOR, step);
|
||||
}
|
||||
|
||||
public double getStep() {
|
||||
return get(STEP_DESCRIPTOR);
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
set(TYPE_DESCRIPTOR, type);
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return get(TYPE_DESCRIPTOR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import com.faendir.acra.ui.base.MyGrid;
|
|||
import com.faendir.acra.ui.base.Path;
|
||||
import com.faendir.acra.ui.base.popup.Popup;
|
||||
import com.faendir.acra.ui.base.popup.ValidatedField;
|
||||
import com.faendir.acra.ui.component.NumberInput;
|
||||
import com.faendir.acra.ui.component.Translatable;
|
||||
import com.faendir.acra.ui.view.app.tabs.BugTab;
|
||||
import com.faendir.acra.util.ImportResult;
|
||||
|
@ -40,6 +39,7 @@ import com.vaadin.flow.component.checkbox.Checkbox;
|
|||
import com.vaadin.flow.component.grid.Grid;
|
||||
import com.vaadin.flow.component.html.Div;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
import com.vaadin.flow.component.textfield.NumberField;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
|
@ -81,7 +81,10 @@ public class Overview extends VerticalLayout implements ComponentEventListener<A
|
|||
}).show();
|
||||
}, Messages.NEW_APP), Translatable.createButton(e -> {
|
||||
Translatable<TextField> host = Translatable.createTextField("localhost", Messages.HOST);
|
||||
NumberInput port = new NumberInput(5984, 0, 65535);
|
||||
NumberField port = new NumberField();
|
||||
port.setValue(5984d);
|
||||
port.setMin(0);
|
||||
port.setMax(65535);
|
||||
Translatable<Checkbox> ssl = Translatable.createCheckbox(false, Messages.SSL);
|
||||
Translatable.Value<TextField> databaseName = Translatable.createTextField("acra-myapp", Messages.DATABASE_NAME);
|
||||
new Popup().setTitle(Messages.IMPORT_ACRALYZER)
|
||||
|
|
|
@ -35,7 +35,6 @@ import com.faendir.acra.ui.component.CssGrid;
|
|||
import com.faendir.acra.ui.component.DownloadButton;
|
||||
import com.faendir.acra.ui.component.FlexLayout;
|
||||
import com.faendir.acra.ui.component.HasSize;
|
||||
import com.faendir.acra.ui.component.NumberInput;
|
||||
import com.faendir.acra.ui.component.RangeInput;
|
||||
import com.faendir.acra.ui.component.Translatable;
|
||||
import com.faendir.acra.ui.view.Overview;
|
||||
|
@ -50,6 +49,7 @@ import com.vaadin.flow.component.html.Div;
|
|||
import com.vaadin.flow.component.icon.Icon;
|
||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||
import com.vaadin.flow.component.orderedlayout.FlexComponent;
|
||||
import com.vaadin.flow.component.textfield.NumberField;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
import com.vaadin.flow.component.upload.Upload;
|
||||
import com.vaadin.flow.component.upload.receivers.MemoryBuffer;
|
||||
|
@ -111,7 +111,12 @@ public class AdminTab extends AppTab<Div> {
|
|||
}, true).show())));
|
||||
versionGrid.appendFooterRow().getCell(versionGrid.getColumns().get(0)).setComponent(Translatable.createButton(e -> {
|
||||
TextField name = new TextField();
|
||||
NumberInput version = new NumberInput(getDataService().getMaxVersion(app).map(i -> i + 1).orElse(1));//, Messages.VERSION_CODE);
|
||||
NumberField version = new NumberField();//, Messages.VERSION_CODE);
|
||||
version.setValue(getDataService().getMaxVersion(app).map(i -> i + 1d).orElse(1d));
|
||||
version.setStep(1d);
|
||||
version.setMin(1d);
|
||||
version.setPreventInvalidInput(true);
|
||||
version.setHasControls(true);
|
||||
MemoryBuffer buffer = new MemoryBuffer();
|
||||
Upload upload = new Upload(buffer);
|
||||
new Popup().setTitle(Messages.NEW_MAPPING)
|
||||
|
@ -197,15 +202,21 @@ public class AdminTab extends AppTab<Div> {
|
|||
.show();
|
||||
}, Messages.NEW_BUG_CONFIG);
|
||||
matchingButton.setWidthFull();
|
||||
NumberInput age = new NumberInput(30);
|
||||
NumberField age = new NumberField();
|
||||
age.setStep(1d);
|
||||
age.setMin(1d);
|
||||
age.setValue(30d);
|
||||
age.setPreventInvalidInput(true);
|
||||
age.setHasControls(true);
|
||||
age.setWidthFull();
|
||||
age.setSuffixComponent(Translatable.createLabel(Messages.REPORTS_OLDER_THAN2));
|
||||
FlexLayout purgeAge = new FlexLayout();
|
||||
purgeAge.setWidthFull();
|
||||
purgeAge.preventWhiteSpaceBreaking();
|
||||
purgeAge.setAlignItems(FlexComponent.Alignment.CENTER);
|
||||
purgeAge.add(Translatable.createButton(e -> getDataService().deleteReportsOlderThanDays(app, age.getValue().intValue()), Messages.PURGE),
|
||||
Translatable.createLabel(Messages.REPORTS_OLDER_THAN1),
|
||||
age, Translatable.createLabel(Messages.REPORTS_OLDER_THAN2));
|
||||
age );
|
||||
purgeAge.expand(age);
|
||||
ComboBox<Integer> versionBox = new ComboBox<>(null, getDataService().getFromReports(app, null, QReport.report.stacktrace.version.code));
|
||||
versionBox.setWidth("100%");
|
||||
|
|
|
@ -34,13 +34,13 @@ import com.faendir.acra.ui.view.bug.tabs.ReportTab;
|
|||
import com.faendir.acra.util.TimeSpanRenderer;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.checkbox.Checkbox;
|
||||
import com.vaadin.flow.component.combobox.ComboBox;
|
||||
import com.vaadin.flow.component.grid.FooterRow;
|
||||
import com.vaadin.flow.component.grid.Grid;
|
||||
import com.vaadin.flow.component.notification.Notification;
|
||||
import com.vaadin.flow.component.orderedlayout.FlexComponent;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
import com.vaadin.flow.component.radiobutton.RadioButtonGroup;
|
||||
import com.vaadin.flow.component.select.Select;
|
||||
import com.vaadin.flow.data.renderer.ComponentRenderer;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
|
@ -99,12 +99,14 @@ public class BugTab extends AppTab<VerticalLayout> {
|
|||
bugs.addColumn(bug -> bug.getBug().getTitle(), QBug.bug.title, Messages.TITLE).setFlexGrow(1);
|
||||
List<Version> versions = getDataService().findAllVersions(app);
|
||||
Grid.Column<VBug> solvedColumn = bugs.addColumn(new ComponentRenderer<>((VBug bug) -> {
|
||||
ComboBox<Version> comboBox = new ComboBox<>("", versions);
|
||||
comboBox.setItemLabelGenerator(Version::getName);
|
||||
comboBox.setValue(bug.getBug().getSolvedVersion());
|
||||
comboBox.setEnabled(SecurityUtils.hasPermission(app, Permission.Level.EDIT));
|
||||
comboBox.addValueChangeListener(e -> getDataService().setBugSolved(bug.getBug(), e.getValue()));
|
||||
return comboBox;
|
||||
Select<Version> versionSelect = new Select<>(versions.toArray(new Version[0]));
|
||||
versionSelect.setTextRenderer(Version::getName);
|
||||
versionSelect.setEmptySelectionAllowed(true);
|
||||
versionSelect.setEmptySelectionCaption(getTranslation(Messages.NOT_SOLVED));
|
||||
versionSelect.setValue(bug.getBug().getSolvedVersion());
|
||||
versionSelect.setEnabled(SecurityUtils.hasPermission(app, Permission.Level.EDIT));
|
||||
versionSelect.addValueChangeListener(e -> getDataService().setBugSolved(bug.getBug(), e.getValue()));
|
||||
return versionSelect;
|
||||
}), QBug.bug.solvedVersion, Messages.SOLVED);
|
||||
bugs.addOnClickNavigation(ReportTab.class, bug -> bug.getBug().getId());
|
||||
FooterRow footerRow = bugs.appendFooterRow();
|
||||
|
|
|
@ -155,4 +155,5 @@ usernameRequired=Sie müssen einen Nutzernamen wählen
|
|||
usernameTaken=Dieser Nutzername ist bereits vergeben
|
||||
passwordRequired=Ein Passwort muss gesetzt werden
|
||||
welcome=Willkommen zu
|
||||
createAdmin=Zuerst müssen Sie einen Adminstrator anlegen:
|
||||
createAdmin=Zuerst müssen Sie einen Adminstrator anlegen:
|
||||
notSolved=Nicht gelöst
|
|
@ -155,4 +155,5 @@ usernameRequired=A username is required
|
|||
usernameTaken=That username is already taken
|
||||
passwordRequired=A password is required
|
||||
welcome=Welcome to
|
||||
createAdmin=First, you have to create an administrator:
|
||||
createAdmin=First, you have to create an administrator:
|
||||
notSolved=Not solved
|
Loading…
Reference in a new issue