Former-commit-id: 8fdc4e53677081e73bb55d785a321c6366fb4177
master
wangbingit@outlook.com 4 years ago
parent 19b94f30bd
commit ec575773cf

@ -117,7 +117,7 @@ public class JavaFxApplication extends Application {
mainController.setMain(this);
mTree = mainController.getDbtree();
mDetail = mainController.getDetail();
mFields = mainController.getFeilds();
mFields = mainController.getFields();
mFields.setEditable(true);
mFields.setSortPolicy(new Callback<TableView, Boolean>() {
@Override
@ -145,7 +145,7 @@ public class JavaFxApplication extends Application {
@Override
public void handle(MouseEvent event) {
int selectedIndex = mFields.getSelectionModel().getSelectedIndex();
if (currentTable== null){
if (currentTable== null || selectedIndex == -1){
return;
}
Field field = currentTable.getFields().get(selectedIndex);
@ -202,7 +202,7 @@ public class JavaFxApplication extends Application {
Dialog.showDictEdit(field);
break;
}
loadTable();
//refreshTable();
JavaFxApplication.this.mFields.getSelectionModel().clearSelection();
}
}
@ -422,7 +422,7 @@ public class JavaFxApplication extends Application {
if (currentMD != null) {
currentTable = projectManager.findTableByTableName(currentMD, (String) targetItem.getValue());
}
loadTable();
initTable();
break;
}
default:
@ -577,7 +577,7 @@ public class JavaFxApplication extends Application {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
currentTable.setSys(newValue);
loadTable();
//refreshTable();
}
});
}
@ -593,7 +593,7 @@ public class JavaFxApplication extends Application {
String fieldName = projectManager.getNewFieldName(fields);
System.out.println("新增字段-" + fieldName + "成功!");
this.mFields.getSelectionModel().select(fields.size() - 1);
loadTable();
//refreshTable();
}
}
@ -603,7 +603,7 @@ public class JavaFxApplication extends Application {
if (selectedIndex > -1 && !currentTable.getFields().get(selectedIndex).getIsSystem()) {
currentTable.getFields().remove(selectedIndex);
mFields.getSelectionModel().clearSelection();
loadTable();
//refreshTable();
}
}
@ -692,7 +692,7 @@ public class JavaFxApplication extends Application {
/**
*
*/
private void loadTable() {
private void initTable() {
GridPane gridPane = mTableLoader.getRoot();
if (currentTable != null) {
detailTableController.getTablename().setText(currentTable.getTableName());
@ -738,7 +738,7 @@ public class JavaFxApplication extends Application {
if (newValue.toUpperCase().endsWith("_TYPE")) {
field.setFieldType(FieldType.Dict);
}
loadTable();
//refreshTable();
}
});
@ -839,7 +839,7 @@ public class JavaFxApplication extends Application {
currentTable.getFields().add(i2, t1);
currentTable.getFields().remove(i2 + 1);
}
loadTable();
//refreshTable();
}
event.setDropCompleted(true);
event.consume();
@ -1046,8 +1046,46 @@ public class JavaFxApplication extends Application {
return checkBoxTableCell;
}
});
columns.get(6).setCellValueFactory(new PropertyValueFactory("isQuery"));
columns.get(6).setCellValueFactory(new PropertyValueFactory("isUnique"));
columns.get(6).setCellFactory(new Callback<TableColumn, TableCell>() {
@Override
public TableCell call(TableColumn param) {
final DBCheckBoxTableCell checkBoxTableCell = new DBCheckBoxTableCell();
DBCheckBoxTableCell.sCallback sCallback = checkBoxTableCell.new sCallback() {
@Override
public ObservableValue<Boolean> call(Integer param) {
super.call(param);
List<Field> fields = currentTable.getFields();
if (fields.get(param).getIsSystem()) {
checkBoxTableCell.setInvalid(true);
} else {
checkBoxTableCell.setInvalid(false);
}
if (fields.get(param).getIsUnique()) {
return new SimpleBooleanProperty(true);
} else {
return new SimpleBooleanProperty(false);
}
}
};
checkBoxTableCell.setSelectedStateCallback(sCallback);
checkBoxTableCell.setOnChangeListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
int param1 = checkBoxTableCell.getParam();
Field field = currentTable.getFields().get(param1);
field.setIsUnique(newValue);
if (newValue) {//
field.setIsQuery(true);
}
}
});
return checkBoxTableCell;
}
});
columns.get(7).setCellValueFactory(new PropertyValueFactory("isQuery"));
columns.get(7).setCellFactory(new Callback<TableColumn, TableCell>() {
@Override
public TableCell call(TableColumn param) {
final DBCheckBoxTableCell checkBoxTableCell = new DBCheckBoxTableCell();
@ -1080,8 +1118,8 @@ public class JavaFxApplication extends Application {
return checkBoxTableCell;
}
});
columns.get(7).setCellValueFactory(new PropertyValueFactory("isSearch"));
columns.get(7).setCellFactory(new Callback<TableColumn, TableCell>() {
columns.get(8).setCellValueFactory(new PropertyValueFactory("isSearch"));
columns.get(8).setCellFactory(new Callback<TableColumn, TableCell>() {
@Override
public TableCell call(TableColumn param) {
final DBCheckBoxTableCell checkBoxTableCell = new DBCheckBoxTableCell();
@ -1114,8 +1152,8 @@ public class JavaFxApplication extends Application {
return checkBoxTableCell;
}
});
columns.get(8).setCellValueFactory(new PropertyValueFactory("fieldComment"));
columns.get(8).setCellFactory(new Callback<TableColumn, TableCell>() {
columns.get(9).setCellValueFactory(new PropertyValueFactory("fieldComment"));
columns.get(9).setCellFactory(new Callback<TableColumn, TableCell>() {
@Override
public TableCell call(TableColumn param) {
@ -1149,14 +1187,11 @@ public class JavaFxApplication extends Application {
}
});
ObservableList<Field> data = null;
if (currentTable != null) {
List<Field> fields = currentTable.getFields();
data = FXCollections.observableArrayList();
data.addAll(fields);
ObservableList<Field> fields = currentTable.getFields();
mFields.setItems(fields);
}
mFields.setItems(data);
}
void ignoreField(TableCell tableCell) {
@ -1198,7 +1233,7 @@ public class JavaFxApplication extends Application {
Table table = projectManager.findTableByTableName(md, (String) event.getOldValue());
if (table != null) {
table.setTableName((String) event.getNewValue());
loadTable();
initTable();
}
break;
}

@ -27,7 +27,7 @@ public class MainController {
@FXML
private Pane detail;
@FXML
private TableView feilds;
private TableView fields;
@FXML
private Button add;
@FXML
@ -69,12 +69,12 @@ public class MainController {
this.sub = sub;
}
public TableView getFeilds() {
return feilds;
public TableView getFields() {
return fields;
}
public void setFeilds(TableView feilds) {
this.feilds = feilds;
public void setFields(TableView fields) {
this.fields = fields;
}
public TreeView getDbtree() {

@ -117,8 +117,9 @@ public class XmlManager {
field.setFieldComment(fieldElement.getAttribute("fieldComment"));
field.setDefaultValue(fieldElement.getAttribute("defaultValue"));
field.setIsSystem(getBoolean(fieldElement.getAttribute("IsSystem")));
field.setIsMust(getBoolean(fieldElement.getAttribute("isMust")));
field.setIsPrimaryKey(getBoolean(fieldElement.getAttribute("isPrimaryKey")));
field.setIsMust(getBoolean(fieldElement.getAttribute("isMust")));
field.setIsUnique(getBoolean(fieldElement.getAttribute("isUnique")));
field.setIsQuery(getBoolean(fieldElement.getAttribute("isQuery")));
field.setIsSearch(getBoolean(fieldElement.getAttribute("isSearch")));
table.putField(field);
@ -236,31 +237,21 @@ public class XmlManager {
table.setAttribute("sys", Boolean.toString(t.getSys()));
Element fields = doc.createElement("fields");
table.appendChild(fields);
for (Field f : t.getFields()) {
Element field = doc.createElement("field");
field.setAttribute("fieldName", f.getFieldName());
if (f.getFieldType() != null) {
field.setAttribute("fieldType", f.getFieldType().name());
}
if (f.getFieldLength() != null) {
field.setAttribute("fieldLength", f.getFieldLength().toString());
}
field.setAttribute("fieldType", f.getFieldType().name());
field.setAttribute("fieldLength", f.getFieldLength().toString());
field.setAttribute("fieldComment", f.getFieldComment());
field.setAttribute("defaultValue", f.getDefaultValue());
if (f.getIsMust() != null) {
field.setAttribute("isMust", f.getIsMust().toString());
}
field.setAttribute("isQuery", f.getIsQuery().toString());
field.setAttribute("isSearch", f.getIsSearch().toString());
if (f.getIsPrimaryKey() != null) {
field.setAttribute("isPrimaryKey", f.getIsPrimaryKey().toString());
}
if (f.getIsSystem() != null) {
field.setAttribute("IsSystem", f.getIsSystem().toString());
}
field.setAttribute("isPrimaryKey", String.valueOf(f.getIsPrimaryKey()));
field.setAttribute("isMust", String.valueOf(f.getIsMust()));
field.setAttribute("isUnique", String.valueOf(f.getIsUnique()));
field.setAttribute("isQuery", String.valueOf(f.getIsQuery()));
field.setAttribute("isSearch", String.valueOf(f.getIsSearch()));
field.setAttribute("IsSystem", String.valueOf(f.getIsSystem()));
if (f.getDictItems().size() > 0) {
for (DictItem dictItem : f.getDictItems()) {
Element dict = doc.createElement("dictItem");

@ -1,5 +1,7 @@
package xyz.wbsite.dbtool.javafx.po;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import org.springframework.util.StringUtils;
import xyz.wbsite.dbtool.javafx.tool.Tool;
@ -34,7 +36,7 @@ public class Field extends Table {
/**
*
*/
private String fieldComment = null;
private String fieldComment = "";
/**
*
@ -44,20 +46,25 @@ public class Field extends Table {
/**
* NULL
*/
private Boolean isMust = false;
private boolean isMust = false;
/**
*
*/
// private boolean isUnique = false;
/**
*
*/
private Boolean isPrimaryKey = false;
private boolean isPrimaryKey = false;
/**
*
*/
private Boolean isQuery = false;
// private boolean isQuery = false;
private Boolean isSearch = false;
private boolean isSearch = false;
private Boolean isSystem = false;
private boolean isSystem = false;
private List<DictItem> dictItems = new ArrayList<>();
@ -150,19 +157,19 @@ public class Field extends Table {
return value;
}
public Boolean getIsSearch() {
public boolean getIsSearch() {
return isSearch;
}
public void setIsSearch(Boolean isSearch) {
public void setIsSearch(boolean isSearch) {
this.isSearch = isSearch;
}
public Boolean getIsSystem() {
public boolean getIsSystem() {
return isSystem;
}
public void setIsSystem(Boolean isSystem) {
public void setIsSystem(boolean isSystem) {
this.isSystem = isSystem;
}
@ -174,12 +181,34 @@ public class Field extends Table {
return "set" + Tool.ABB2Abb(this.fieldName);
}
public Boolean getIsQuery() {
// isUnique
private final BooleanProperty isUnique = new SimpleBooleanProperty();
public BooleanProperty isUniqueProperty() {
return isUnique;
}
public boolean getIsUnique() {
return isUnique.get();
}
public void setIsUnique(boolean isUnique) {
this.isUnique.set(isUnique);
}
// isQuery
private final BooleanProperty isQuery = new SimpleBooleanProperty();
public BooleanProperty isQueryProperty() {
return isQuery;
}
public void setIsQuery(Boolean isQuery) {
this.isQuery = isQuery;
public boolean getIsQuery() {
return isQuery.get();
}
public void setIsQuery(boolean isQuery) {
this.isQuery.set(isQuery);
}
public String getFieldName() {
@ -222,19 +251,19 @@ public class Field extends Table {
this.defaultValue = defaultValue;
}
public Boolean getIsMust() {
public boolean getIsMust() {
return isMust;
}
public void setIsMust(Boolean isMust) {
public void setIsMust(boolean isMust) {
this.isMust = isMust;
}
public Boolean getIsPrimaryKey() {
public boolean getIsPrimaryKey() {
return isPrimaryKey;
}
public void setIsPrimaryKey(Boolean isPrimaryKey) {
public void setIsPrimaryKey(boolean isPrimaryKey) {
this.isPrimaryKey = isPrimaryKey;
}

@ -1,5 +1,7 @@
package xyz.wbsite.dbtool.javafx.po;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.control.TreeItem;
import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
@ -49,7 +51,7 @@ public class Table extends TreeItem {
/**
*
*/
private List<Field> fields = new ArrayList();
private ObservableList<Field> fields = FXCollections.observableArrayList();
public boolean has(String type) {
for (Field field : fields) {
@ -73,17 +75,11 @@ public class Table extends TreeItem {
}
public boolean putField(Field field) {
if (fields == null) {
fields = new ArrayList<Field>();
}
fields.add(field);
return true;
}
public boolean putFirstField(Field field) {
if (fields == null) {
fields = new ArrayList<Field>();
}
fields.add(0, field);
return true;
}
@ -117,14 +113,10 @@ public class Table extends TreeItem {
this.tableComment = tableComment != null ? tableComment : "";
}
public List<Field> getFields() {
public ObservableList<Field> getFields() {
return fields;
}
public void setFields(List<Field> fields) {
this.fields = fields;
}
public Module getdBhandle() {
return dBhandle;
}

@ -57,7 +57,7 @@
<Pane fx:id="detail" prefHeight="200.0" prefWidth="200.0"/>
<BorderPane>
<center>
<TableView fx:id="feilds" prefHeight="200.0" prefWidth="200.0">
<TableView fx:id="fields" prefHeight="200.0" prefWidth="200.0">
<columns>
<TableColumn prefWidth="100" text="字段名"/>
<TableColumn prefWidth="90" text="类型"/>
@ -65,6 +65,7 @@
<TableColumn prefWidth="40" text="默认值"/>
<TableColumn prefWidth="35" text="主键"/>
<TableColumn prefWidth="35" text="必填"/>
<TableColumn prefWidth="35" text="唯一"/>
<TableColumn prefWidth="35" text="查询"/>
<TableColumn prefWidth="35" text="模糊"/>
<TableColumn prefWidth="90" text="注释"/>

@ -108,10 +108,10 @@ public class DataInit {
<#list module.tables as table>
<#list table.fields as field>
<#if field.fieldType == 'Dict'>
{// ${field.fieldComment}
createDict("${field.fieldName}", "${field.fieldComment}", new String[][]{
{// ${field.fieldComment?default('')}
createDict("${field.fieldName?default('')}", "${field.fieldComment?default('')}", new String[][]{
<#list field.dictItems as dictItem>
{"${dictItem.key}", "${dictItem.value}"},
{"${dictItem.key?default('')}", "${dictItem.value?default('')}"},
</#list>
});
}

Loading…
Cancel
Save

Powered by TurnKey Linux.