parent
e75fa146a2
commit
bb510ef009
@ -0,0 +1,149 @@
|
|||||||
|
package xyz.wbsite.dbtool.javafx.ctrl;
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.TableCell;
|
||||||
|
import javafx.scene.control.TableColumn;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
|
import javafx.scene.control.cell.TextFieldTableCell;
|
||||||
|
import javafx.util.Callback;
|
||||||
|
import javafx.util.converter.DefaultStringConverter;
|
||||||
|
import xyz.wbsite.dbtool.javafx.po.SelectItem;
|
||||||
|
import xyz.wbsite.dbtool.javafx.po.SelectItem;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class OptionSelectController {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button start;
|
||||||
|
@FXML
|
||||||
|
private Button cancel;
|
||||||
|
@FXML
|
||||||
|
private TableView datas;
|
||||||
|
@FXML
|
||||||
|
private Button add;
|
||||||
|
@FXML
|
||||||
|
private Button sub;
|
||||||
|
|
||||||
|
private List<SelectItem> data = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<SelectItem> getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(List<SelectItem> data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Button getStart() {
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStart(Button start) {
|
||||||
|
this.start = start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Button getCancel() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancel(Button cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableView getDatas() {
|
||||||
|
return datas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatas(TableView datas) {
|
||||||
|
this.datas = datas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Button getAdd() {
|
||||||
|
return add;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdd(Button add) {
|
||||||
|
this.add = add;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Button getSub() {
|
||||||
|
return sub;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSub(Button sub) {
|
||||||
|
this.sub = sub;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initData() {
|
||||||
|
datas.setEditable(true);
|
||||||
|
datas.setSortPolicy(new Callback<TableView, Boolean>() {
|
||||||
|
@Override
|
||||||
|
public Boolean call(TableView param) {
|
||||||
|
//禁止点击列头排序
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ObservableList<TableColumn> columns = datas.getColumns();
|
||||||
|
columns.get(0).setCellValueFactory(new PropertyValueFactory("value"));
|
||||||
|
columns.get(0).setCellFactory(new Callback<TableColumn, TableCell>() {
|
||||||
|
@Override
|
||||||
|
public TableCell call(TableColumn param) {
|
||||||
|
|
||||||
|
param.setOnEditCommit(new EventHandler<TableColumn.CellEditEvent>() {
|
||||||
|
@Override
|
||||||
|
public void handle(TableColumn.CellEditEvent event) {
|
||||||
|
int row = event.getTablePosition().getRow();
|
||||||
|
SelectItem field = data.get(row);
|
||||||
|
field.setValue((String) event.getNewValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return new TextFieldTableCell(new DefaultStringConverter()) {
|
||||||
|
@Override
|
||||||
|
public void updateItem(Object item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
int index = this.getTableRow().getIndex();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ObservableList<SelectItem> ObservableList = FXCollections.observableArrayList();
|
||||||
|
ObservableList.addAll(data);
|
||||||
|
datas.setItems(ObservableList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh(){
|
||||||
|
ObservableList<SelectItem> ObservableList = FXCollections.observableArrayList();
|
||||||
|
ObservableList.addAll(data);
|
||||||
|
datas.setItems(ObservableList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelectItem getNewSelectItem() {
|
||||||
|
String baseValue = "VALUE";
|
||||||
|
String value = baseValue;
|
||||||
|
int k = 0;
|
||||||
|
do {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < data.size(); i++) {
|
||||||
|
if (value.equals(data.get(i).getValue())) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i < data.size()) {
|
||||||
|
k++;
|
||||||
|
value = baseValue + k;
|
||||||
|
} else {
|
||||||
|
SelectItem SelectItem = new SelectItem();
|
||||||
|
SelectItem.setValue(value);
|
||||||
|
return SelectItem;
|
||||||
|
}
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package xyz.wbsite.dbtool.javafx.po;
|
||||||
|
|
||||||
|
|
||||||
|
import xyz.wbsite.dbtool.javafx.annotation.Property;
|
||||||
|
|
||||||
|
public class SelectItem {
|
||||||
|
@Property("value")
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<BorderPane fx:controller="xyz.wbsite.dbtool.javafx.ctrl.OptionSelectController"
|
||||||
|
maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
|
||||||
|
minWidth="-Infinity" prefHeight="200.0" prefWidth="300.0"
|
||||||
|
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
|
<top>
|
||||||
|
<ToolBar prefHeight="30.0" prefWidth="300.0" BorderPane.alignment="CENTER">
|
||||||
|
<items>
|
||||||
|
<Button fx:id="add" mnemonicParsing="false" text=" + "/>
|
||||||
|
<Button fx:id="sub" mnemonicParsing="false" text=" - "/>
|
||||||
|
</items>
|
||||||
|
</ToolBar>
|
||||||
|
</top>
|
||||||
|
<opaqueInsets>
|
||||||
|
<Insets/>
|
||||||
|
</opaqueInsets>
|
||||||
|
<BorderPane.margin>
|
||||||
|
<Insets top="20.0"/>
|
||||||
|
</BorderPane.margin>
|
||||||
|
<center>
|
||||||
|
<TableView fx:id="datas" prefHeight="170.0" prefWidth="300.0" BorderPane.alignment="CENTER">
|
||||||
|
<columns>
|
||||||
|
<TableColumn prefWidth="198.0" text="选项值"/>
|
||||||
|
</columns>
|
||||||
|
</TableView>
|
||||||
|
</center>
|
||||||
|
<bottom>
|
||||||
|
<GridPane prefHeight="45.0" prefWidth="300.0" BorderPane.alignment="CENTER">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="80.0"/>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="80.0"/>
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Button fx:id="start" mnemonicParsing="false" text="确认" GridPane.halignment="CENTER"
|
||||||
|
GridPane.valignment="CENTER"/>
|
||||||
|
<Button fx:id="cancel" mnemonicParsing="false" text="取消" GridPane.columnIndex="1"
|
||||||
|
GridPane.halignment="CENTER"
|
||||||
|
GridPane.valignment="CENTER"/>
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
|
</bottom>
|
||||||
|
</BorderPane>
|
@ -1,4 +1,4 @@
|
|||||||
package ${domain}.action.ajax.wsys;
|
package ${domain}.action.ajax.wmnt;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
@ -1,4 +1,4 @@
|
|||||||
package ${domain}.action.ajax.wsys;
|
package ${domain}.action.ajax.wmnt;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import ${domain}.frame.base.ErrorType;
|
import ${domain}.frame.base.ErrorType;
|
Loading…
Reference in new issue