|
|
|
@ -57,16 +57,16 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class JavaFxApplication extends Application {
|
|
|
|
|
|
|
|
|
|
private ProjectManager dBmanger = ManagerFactory.getProjectManager();
|
|
|
|
|
private TreeView mdtree = null;
|
|
|
|
|
private Pane detail = null;
|
|
|
|
|
private TableView feilds = null;
|
|
|
|
|
private ProjectManager dBmanager = ManagerFactory.getProjectManager();
|
|
|
|
|
private TreeView mTree = null;
|
|
|
|
|
private Pane mDetail = null;
|
|
|
|
|
private TableView mFields = null;
|
|
|
|
|
private Button add = null;
|
|
|
|
|
private Button sub = null;
|
|
|
|
|
private FXMLLoader mainloader;
|
|
|
|
|
private FXMLLoader projectdetailloader;
|
|
|
|
|
private FXMLLoader mddetailloader;
|
|
|
|
|
private FXMLLoader tabledetailloader;
|
|
|
|
|
private FXMLLoader mMainLoader;
|
|
|
|
|
private FXMLLoader mProjectLoader;
|
|
|
|
|
private FXMLLoader mModuleLoader;
|
|
|
|
|
private FXMLLoader mTableLoader;
|
|
|
|
|
private MainController mainController;
|
|
|
|
|
private DetailProjectController detailProjectController;
|
|
|
|
|
private DetailModuleController mdDetailController;
|
|
|
|
@ -83,7 +83,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
@Override
|
|
|
|
|
public void start(Stage primaryStage) throws Exception {
|
|
|
|
|
|
|
|
|
|
BorderPane root = mainloader.getRoot();
|
|
|
|
|
BorderPane root = mMainLoader.getRoot();
|
|
|
|
|
|
|
|
|
|
primaryStage.setTitle("DBtool");
|
|
|
|
|
primaryStage.setScene(new Scene(root, 700, 500));
|
|
|
|
@ -105,15 +105,15 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
if (main == null) {
|
|
|
|
|
main = getClass().getResource("../../../fxml/main.fxml");
|
|
|
|
|
}
|
|
|
|
|
mainloader = new FXMLLoader(main);
|
|
|
|
|
mainloader.load();
|
|
|
|
|
mainController = mainloader.getController();
|
|
|
|
|
mMainLoader = new FXMLLoader(main);
|
|
|
|
|
mMainLoader.load();
|
|
|
|
|
mainController = mMainLoader.getController();
|
|
|
|
|
mainController.setMain(this);
|
|
|
|
|
mdtree = mainController.getDbtree();
|
|
|
|
|
detail = mainController.getDetail();
|
|
|
|
|
feilds = mainController.getFeilds();
|
|
|
|
|
feilds.setEditable(true);
|
|
|
|
|
feilds.setSortPolicy(new Callback<TableView, Boolean>() {
|
|
|
|
|
mTree = mainController.getDbtree();
|
|
|
|
|
mDetail = mainController.getDetail();
|
|
|
|
|
mFields = mainController.getFeilds();
|
|
|
|
|
mFields.setEditable(true);
|
|
|
|
|
mFields.setSortPolicy(new Callback<TableView, Boolean>() {
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean call(TableView param) {
|
|
|
|
|
//禁止点击列头排序
|
|
|
|
@ -140,7 +140,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
@Override
|
|
|
|
|
public void handle(ActionEvent event) {
|
|
|
|
|
MenuItem target = (MenuItem) event.getTarget();
|
|
|
|
|
int index = feilds.getSelectionModel().getSelectedIndex();
|
|
|
|
|
int index = mFields.getSelectionModel().getSelectedIndex();
|
|
|
|
|
List<Field> fields = currentTable.getFields();
|
|
|
|
|
|
|
|
|
|
if ("新增".equals(target.getText())) {
|
|
|
|
@ -170,11 +170,11 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
loadingTable();
|
|
|
|
|
feilds.getSelectionModel().clearSelection();
|
|
|
|
|
JavaFxApplication.this.mFields.getSelectionModel().clearSelection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
feilds.setContextMenu(con);
|
|
|
|
|
mFields.setContextMenu(con);
|
|
|
|
|
|
|
|
|
|
project_menu = new ContextMenu(new MenuItem("新增模块"));
|
|
|
|
|
md_right_menu = new ContextMenu(new MenuItem("新增对象"), new MenuItem("删除模块"), new MenuItem("向上调整"), new MenuItem("向下调整"));
|
|
|
|
@ -187,31 +187,31 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
if (projectdetail == null) {
|
|
|
|
|
projectdetail = getClass().getResource("../../../fxml/projectdetail.fxml");
|
|
|
|
|
}
|
|
|
|
|
projectdetailloader = new FXMLLoader(projectdetail);
|
|
|
|
|
projectdetailloader.load();
|
|
|
|
|
detailProjectController = projectdetailloader.getController();
|
|
|
|
|
mProjectLoader = new FXMLLoader(projectdetail);
|
|
|
|
|
mProjectLoader.load();
|
|
|
|
|
detailProjectController = mProjectLoader.getController();
|
|
|
|
|
|
|
|
|
|
URL mddetail = JavaFxApplication.class.getClassLoader().getResource("fxml/moduledetail.fxml");
|
|
|
|
|
if (mddetail == null) {
|
|
|
|
|
mddetail = getClass().getResource("../../../fxml/moduledetail.fxml");
|
|
|
|
|
}
|
|
|
|
|
mddetailloader = new FXMLLoader(mddetail);
|
|
|
|
|
mddetailloader.load();
|
|
|
|
|
mdDetailController = mddetailloader.getController();
|
|
|
|
|
mModuleLoader = new FXMLLoader(mddetail);
|
|
|
|
|
mModuleLoader.load();
|
|
|
|
|
mdDetailController = mModuleLoader.getController();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
URL tabledetail = JavaFxApplication.class.getClassLoader().getResource("fxml/tabledetail.fxml");
|
|
|
|
|
if (tabledetail == null) {
|
|
|
|
|
tabledetail = getClass().getResource("../../../fxml/tabledetail.fxml");
|
|
|
|
|
}
|
|
|
|
|
tabledetailloader = new FXMLLoader(tabledetail);
|
|
|
|
|
tabledetailloader.load();
|
|
|
|
|
detailTableController = tabledetailloader.getController();
|
|
|
|
|
mTableLoader = new FXMLLoader(tabledetail);
|
|
|
|
|
mTableLoader.load();
|
|
|
|
|
detailTableController = mTableLoader.getController();
|
|
|
|
|
|
|
|
|
|
mdtree.setShowRoot(true);
|
|
|
|
|
mdtree.setEditable(true);
|
|
|
|
|
mdtree.setDisable(false);
|
|
|
|
|
mdtree.setCellFactory(new Callback<TreeView, TreeCell>() {
|
|
|
|
|
mTree.setShowRoot(true);
|
|
|
|
|
mTree.setEditable(true);
|
|
|
|
|
mTree.setDisable(false);
|
|
|
|
|
mTree.setCellFactory(new Callback<TreeView, TreeCell>() {
|
|
|
|
|
@Override
|
|
|
|
|
public TreeCell call(TreeView param) {
|
|
|
|
|
TextFieldTreeCell textFieldTreeCell = new TextFieldTreeCell(new DefaultStringConverter());
|
|
|
|
@ -224,7 +224,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
public void handle(MouseEvent event) {
|
|
|
|
|
TextFieldTreeCell source = (TextFieldTreeCell) event.getSource();
|
|
|
|
|
String text = source.getText();
|
|
|
|
|
Module dbByDBName = dBmanger.findDBByDBName(text);
|
|
|
|
|
Module dbByDBName = dBmanager.findDBByDBName(text);
|
|
|
|
|
if (dbByDBName != null) {
|
|
|
|
|
dragMD = true;
|
|
|
|
|
} else {
|
|
|
|
@ -248,7 +248,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
Dragboard md = event.getDragboard();
|
|
|
|
|
TextFieldTreeCell source = (TextFieldTreeCell) event.getSource();
|
|
|
|
|
|
|
|
|
|
Module dbByDBName = dBmanger.findDBByDBName(source.getText());
|
|
|
|
|
Module dbByDBName = dBmanager.findDBByDBName(source.getText());
|
|
|
|
|
|
|
|
|
|
if (dragMD && dbByDBName != null) {
|
|
|
|
|
double y = event.getY();
|
|
|
|
@ -284,7 +284,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
String m2 = ((TreeCell<String>) event.getGestureTarget()).getItem();
|
|
|
|
|
|
|
|
|
|
if (dragMD) {
|
|
|
|
|
List<Module> mds = dBmanger.getMds();
|
|
|
|
|
List<Module> mds = dBmanager.getMds();
|
|
|
|
|
|
|
|
|
|
int i1 = 0, i2 = 0;
|
|
|
|
|
for (int i = 0; i < mds.size(); i++) {
|
|
|
|
@ -346,19 +346,19 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
}
|
|
|
|
|
event.setDropCompleted(true);
|
|
|
|
|
event.consume();
|
|
|
|
|
mdtree.getSelectionModel().clearSelection();
|
|
|
|
|
int focusedIndex = mdtree.getFocusModel().getFocusedIndex();
|
|
|
|
|
mTree.getSelectionModel().clearSelection();
|
|
|
|
|
int focusedIndex = mTree.getFocusModel().getFocusedIndex();
|
|
|
|
|
System.out.println(focusedIndex);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return textFieldTreeCell;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
mdtree.setOnEditCommit(new YEventHandler());
|
|
|
|
|
mdtree.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
|
|
|
|
mTree.setOnEditCommit(new YEventHandler());
|
|
|
|
|
mTree.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void handle(MouseEvent event) {
|
|
|
|
|
TreeItem targetItem = (TreeItem) mdtree.getSelectionModel().getSelectedItem();
|
|
|
|
|
TreeItem targetItem = (TreeItem) mTree.getSelectionModel().getSelectedItem();
|
|
|
|
|
|
|
|
|
|
if (targetItem == null)
|
|
|
|
|
return;
|
|
|
|
@ -367,24 +367,24 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
|
|
|
|
|
switch (level) {
|
|
|
|
|
case 0: {//查看模块
|
|
|
|
|
mdtree.setContextMenu(project_menu);
|
|
|
|
|
mTree.setContextMenu(project_menu);
|
|
|
|
|
loadingProject();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1: {//查看模块
|
|
|
|
|
|
|
|
|
|
mdtree.setContextMenu(md_right_menu);
|
|
|
|
|
currentMD = dBmanger.findDBByDBName((String) targetItem.getValue());
|
|
|
|
|
mTree.setContextMenu(md_right_menu);
|
|
|
|
|
currentMD = dBmanager.findDBByDBName((String) targetItem.getValue());
|
|
|
|
|
currentTable = null;
|
|
|
|
|
loadingModule();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2: {//查看对象
|
|
|
|
|
mdtree.setContextMenu(table_right_menu);
|
|
|
|
|
mTree.setContextMenu(table_right_menu);
|
|
|
|
|
TreeItem parent = targetItem.getParent();
|
|
|
|
|
currentMD = dBmanger.findDBByDBName((String) parent.getValue());
|
|
|
|
|
currentMD = dBmanager.findDBByDBName((String) parent.getValue());
|
|
|
|
|
if (currentMD != null) {
|
|
|
|
|
currentTable = dBmanger.findTableByTableName(currentMD, (String) targetItem.getValue());
|
|
|
|
|
currentTable = dBmanager.findTableByTableName(currentMD, (String) targetItem.getValue());
|
|
|
|
|
}
|
|
|
|
|
loadingTable();
|
|
|
|
|
break;
|
|
|
|
@ -533,21 +533,21 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addField() {
|
|
|
|
|
if (currentTable != null && feilds != null) {
|
|
|
|
|
if (currentTable != null && mFields != null) {
|
|
|
|
|
List<Field> fields = currentTable.getFields();
|
|
|
|
|
String fieldName = dBmanger.getNewFieldName(fields);
|
|
|
|
|
String fieldName = dBmanager.getNewFieldName(fields);
|
|
|
|
|
System.out.println("新增字段-" + fieldName + "成功!");
|
|
|
|
|
feilds.getSelectionModel().select(fields.size() - 1);
|
|
|
|
|
this.mFields.getSelectionModel().select(fields.size() - 1);
|
|
|
|
|
loadingTable();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void subField() {
|
|
|
|
|
if (currentTable != null) {
|
|
|
|
|
int selectedIndex = feilds.getSelectionModel().getSelectedIndex();
|
|
|
|
|
int selectedIndex = mFields.getSelectionModel().getSelectedIndex();
|
|
|
|
|
if (selectedIndex > -1 && !currentTable.getFields().get(selectedIndex).getIsSystem()) {
|
|
|
|
|
currentTable.getFields().remove(selectedIndex);
|
|
|
|
|
feilds.getSelectionModel().clearSelection();
|
|
|
|
|
mFields.getSelectionModel().clearSelection();
|
|
|
|
|
loadingTable();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -555,11 +555,11 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void loadingProjectTree() {
|
|
|
|
|
currentProject = dBmanger.getProject();
|
|
|
|
|
currentProject = dBmanager.getProject();
|
|
|
|
|
currentProject.setValue(currentProject.getProjectName());
|
|
|
|
|
currentProject.setExpanded(true);
|
|
|
|
|
|
|
|
|
|
mdtree.setRoot(currentProject);
|
|
|
|
|
mTree.setRoot(currentProject);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < currentProject.getModules().size(); i++) {
|
|
|
|
|
Module module = currentProject.getModules().get(i);
|
|
|
|
@ -574,7 +574,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int getLevel(TreeItem treeItem) {
|
|
|
|
|
TreeItem root = mdtree.getRoot();
|
|
|
|
|
TreeItem root = mTree.getRoot();
|
|
|
|
|
int level = 0;
|
|
|
|
|
if (treeItem == root) {
|
|
|
|
|
level = 0;
|
|
|
|
@ -591,22 +591,22 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GridPane gridPane = mddetailloader.getRoot();
|
|
|
|
|
GridPane gridPane = mModuleLoader.getRoot();
|
|
|
|
|
mdDetailController.getModuleComment().setText(currentMD.getModuleComment());
|
|
|
|
|
mdDetailController.getModulePrefix().setText(currentMD.getModulePrefix());
|
|
|
|
|
mdDetailController.getModuleName().setText(currentMD.getModuleName());
|
|
|
|
|
|
|
|
|
|
if (gridPane != null) {
|
|
|
|
|
detail.getChildren().clear();
|
|
|
|
|
detail.getChildren().add(gridPane);
|
|
|
|
|
mDetail.getChildren().clear();
|
|
|
|
|
mDetail.getChildren().add(gridPane);
|
|
|
|
|
}
|
|
|
|
|
if (feilds != null && feilds.getItems() != null) {
|
|
|
|
|
feilds.getItems().clear();
|
|
|
|
|
if (mFields != null && mFields.getItems() != null) {
|
|
|
|
|
mFields.getItems().clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void loadingProject() {
|
|
|
|
|
GridPane gridPane = projectdetailloader.getRoot();
|
|
|
|
|
GridPane gridPane = mProjectLoader.getRoot();
|
|
|
|
|
detailProjectController.getProjectName().setText(currentProject.getProjectName());
|
|
|
|
|
detailProjectController.getProjectBasePackage().setText(currentProject.getProjectBasePackage());
|
|
|
|
|
detailProjectController.getProjectAuthor().setText(currentProject.getProjectAuthor());
|
|
|
|
@ -614,11 +614,11 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
detailProjectController.getSysMD().setSelected(currentProject.getSysMD());
|
|
|
|
|
|
|
|
|
|
if (gridPane != null) {
|
|
|
|
|
detail.getChildren().clear();
|
|
|
|
|
detail.getChildren().add(gridPane);
|
|
|
|
|
mDetail.getChildren().clear();
|
|
|
|
|
mDetail.getChildren().add(gridPane);
|
|
|
|
|
}
|
|
|
|
|
if (feilds != null && feilds.getItems() != null) {
|
|
|
|
|
feilds.getItems().clear();
|
|
|
|
|
if (mFields != null && mFields.getItems() != null) {
|
|
|
|
|
mFields.getItems().clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -626,7 +626,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
* 加载对象信息
|
|
|
|
|
*/
|
|
|
|
|
private void loadingTable() {
|
|
|
|
|
GridPane gridPane = tabledetailloader.getRoot();
|
|
|
|
|
GridPane gridPane = mTableLoader.getRoot();
|
|
|
|
|
if (currentTable != null) {
|
|
|
|
|
detailTableController.getTablename().setText(currentTable.getTableName());
|
|
|
|
|
detailTableController.getTablecomment().setText(currentTable.getTableComment());
|
|
|
|
@ -641,10 +641,10 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gridPane != null) {
|
|
|
|
|
detail.getChildren().clear();
|
|
|
|
|
detail.getChildren().add(gridPane);
|
|
|
|
|
mDetail.getChildren().clear();
|
|
|
|
|
mDetail.getChildren().add(gridPane);
|
|
|
|
|
}
|
|
|
|
|
ObservableList<TableColumn> columns = feilds.getColumns();
|
|
|
|
|
ObservableList<TableColumn> columns = mFields.getColumns();
|
|
|
|
|
columns.get(0).setCellValueFactory(new PropertyValueFactory<Field, String>("fieldName"));
|
|
|
|
|
columns.get(0).setCellFactory(new Callback<TableColumn, TableCell>() {
|
|
|
|
|
@Override
|
|
|
|
@ -794,7 +794,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
FieldType fieldType = field.getFieldType();
|
|
|
|
|
if (fieldType.isFix() && fieldType.getDefaultLength() != field.getFieldLength()) {
|
|
|
|
|
field.setFieldLength(fieldType.getDefaultLength());
|
|
|
|
|
feilds.refresh();
|
|
|
|
|
mFields.refresh();
|
|
|
|
|
}
|
|
|
|
|
if (field.getIsSystem()) {
|
|
|
|
|
ignoreField(this);
|
|
|
|
@ -819,7 +819,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
FieldType newValue = (FieldType) event.getNewValue();
|
|
|
|
|
field.setFieldLength(newValue.getDefaultLength());
|
|
|
|
|
field.setFieldType(newValue);
|
|
|
|
|
feilds.refresh();
|
|
|
|
|
mFields.refresh();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return choiceBoxTableCell;
|
|
|
|
@ -841,7 +841,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
feilds.refresh();
|
|
|
|
|
mFields.refresh();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new IntegerStringConverter()) {
|
|
|
|
@ -1079,7 +1079,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
data.addAll(fields);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
feilds.setItems(data);
|
|
|
|
|
mFields.setItems(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ignoreField(TableCell tableCell) {
|
|
|
|
@ -1105,20 +1105,20 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
|
|
|
|
|
switch (level) {
|
|
|
|
|
case 0: {//编辑项目名称
|
|
|
|
|
dBmanger.getProject().setProjectName((String) event.getNewValue());
|
|
|
|
|
dBmanager.getProject().setProjectName((String) event.getNewValue());
|
|
|
|
|
loadingProject();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1: {//编辑模块
|
|
|
|
|
Module md = dBmanger.findDBByDBName((String) event.getOldValue());
|
|
|
|
|
Module md = dBmanager.findDBByDBName((String) event.getOldValue());
|
|
|
|
|
md.setModuleName((String) event.getNewValue());
|
|
|
|
|
loadingModule();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2: {//编辑对象
|
|
|
|
|
TreeItem parent = treeItem.getParent();
|
|
|
|
|
Module md = dBmanger.findDBByDBName((String) parent.getValue());
|
|
|
|
|
Table table = dBmanger.findTableByTableName(md, (String) event.getOldValue());
|
|
|
|
|
Module md = dBmanager.findDBByDBName((String) parent.getValue());
|
|
|
|
|
Table table = dBmanager.findTableByTableName(md, (String) event.getOldValue());
|
|
|
|
|
if (table != null) {
|
|
|
|
|
table.setTableName((String) event.getNewValue());
|
|
|
|
|
loadingTable();
|
|
|
|
@ -1141,40 +1141,40 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
MenuItem target = (MenuItem) event.getTarget();
|
|
|
|
|
|
|
|
|
|
String text = target.getText();
|
|
|
|
|
Project project = (Project) mdtree.getRoot();
|
|
|
|
|
Project project = (Project) mTree.getRoot();
|
|
|
|
|
|
|
|
|
|
TreeItem targetItem = (TreeItem) mdtree.getFocusModel().getFocusedItem();
|
|
|
|
|
TreeItem targetItem = (TreeItem) mTree.getFocusModel().getFocusedItem();
|
|
|
|
|
int index = -1;
|
|
|
|
|
index = mdtree.getFocusModel().getFocusedIndex();
|
|
|
|
|
index = mTree.getFocusModel().getFocusedIndex();
|
|
|
|
|
if (targetItem == null) {
|
|
|
|
|
targetItem = (TreeItem) mdtree.getSelectionModel().getSelectedItem();
|
|
|
|
|
targetItem = (TreeItem) mTree.getSelectionModel().getSelectedItem();
|
|
|
|
|
}
|
|
|
|
|
if (index == -1) {
|
|
|
|
|
index = mdtree.getSelectionModel().getSelectedIndex();
|
|
|
|
|
index = mTree.getSelectionModel().getSelectedIndex();
|
|
|
|
|
}
|
|
|
|
|
if (text != null && targetItem != null) {
|
|
|
|
|
switch (text) {
|
|
|
|
|
|
|
|
|
|
case "向上调整":
|
|
|
|
|
if (index > 0) {
|
|
|
|
|
Tool.exchange(dBmanger.getProject().getModules(), index - 1, index);
|
|
|
|
|
Tool.exchange(dBmanger.getProject().getChildren(), index - 1, index);
|
|
|
|
|
Tool.exchange(dBmanager.getProject().getModules(), index - 1, index);
|
|
|
|
|
Tool.exchange(dBmanager.getProject().getChildren(), index - 1, index);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "向下调整":
|
|
|
|
|
List<Module> mds = dBmanger.getMds();
|
|
|
|
|
List<Module> mds = dBmanager.getMds();
|
|
|
|
|
if (index < mds.size() - 1) {
|
|
|
|
|
Tool.exchange(dBmanger.getProject().getModules(), index, index + 1);
|
|
|
|
|
Tool.exchange(dBmanger.getProject().getChildren(), index, index + 1);
|
|
|
|
|
Tool.exchange(dBmanager.getProject().getModules(), index, index + 1);
|
|
|
|
|
Tool.exchange(dBmanager.getProject().getChildren(), index, index + 1);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "新增模块":
|
|
|
|
|
dBmanger.getNewModuleName();
|
|
|
|
|
dBmanager.getNewModuleName();
|
|
|
|
|
break;
|
|
|
|
|
case "删除模块":
|
|
|
|
|
if (targetItem != null && targetItem.getParent() == project) {
|
|
|
|
|
currentProject.getChildren().remove(targetItem);
|
|
|
|
|
boolean b = dBmanger.removeDBByDBName((String) targetItem.getValue());
|
|
|
|
|
boolean b = dBmanager.removeDBByDBName((String) targetItem.getValue());
|
|
|
|
|
if (b) {
|
|
|
|
|
System.out.println("删除模块" + targetItem.getValue() + "成功!");
|
|
|
|
|
}
|
|
|
|
@ -1186,9 +1186,9 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
switch (level) {
|
|
|
|
|
case 1: {//对模块右击
|
|
|
|
|
System.out.println("模块:" + targetItem.getValue());
|
|
|
|
|
Module md = dBmanger.findDBByDBName((String) targetItem.getValue());
|
|
|
|
|
Module md = dBmanager.findDBByDBName((String) targetItem.getValue());
|
|
|
|
|
if (md != null) {
|
|
|
|
|
Table newTableName = dBmanger.getNewTableName(md);
|
|
|
|
|
Table newTableName = dBmanager.getNewTableName(md);
|
|
|
|
|
targetItem.getChildren().add(newTableName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1196,8 +1196,8 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
case 2: {//对对象右击
|
|
|
|
|
TreeItem parent = targetItem.getParent();
|
|
|
|
|
System.out.println("对象:" + parent.getValue());
|
|
|
|
|
Module md = dBmanger.findDBByDBName((String) parent.getValue());
|
|
|
|
|
Table newTableName = dBmanger.getNewTableName(md);
|
|
|
|
|
Module md = dBmanager.findDBByDBName((String) parent.getValue());
|
|
|
|
|
Table newTableName = dBmanager.getNewTableName(md);
|
|
|
|
|
parent.getChildren().add(new TreeItem<>(newTableName.getTableName()));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -1215,15 +1215,15 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
switch (level) {
|
|
|
|
|
case 0: {//对模块右击
|
|
|
|
|
System.out.println("模块:" + targetItem.getValue());
|
|
|
|
|
Module md = dBmanger.findDBByDBName((String) targetItem.getValue());
|
|
|
|
|
Table newTableName = dBmanger.getNewTableName(md);
|
|
|
|
|
Module md = dBmanager.findDBByDBName((String) targetItem.getValue());
|
|
|
|
|
Table newTableName = dBmanager.getNewTableName(md);
|
|
|
|
|
targetItem.getChildren().add(new TreeItem<>(newTableName.getTableName()));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1: {//对对象右击
|
|
|
|
|
TreeItem parent = targetItem.getParent();
|
|
|
|
|
System.out.println("对象:" + parent.getValue());
|
|
|
|
|
Module md = dBmanger.findDBByDBName((String) parent.getValue());
|
|
|
|
|
Module md = dBmanager.findDBByDBName((String) parent.getValue());
|
|
|
|
|
|
|
|
|
|
for (Table table : md.getTables()) {
|
|
|
|
|
if (table.getTableName().equals(targetItem.getValue())) {
|
|
|
|
@ -1243,7 +1243,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
} else if (text != null && targetItem == null) {
|
|
|
|
|
switch (text) {
|
|
|
|
|
case "新增模块":
|
|
|
|
|
dBmanger.getNewModuleName();
|
|
|
|
|
dBmanager.getNewModuleName();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
@ -1253,7 +1253,7 @@ public class JavaFxApplication extends Application {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateDbTree(List<Module> mds) {
|
|
|
|
|
TreeItem root = mdtree.getRoot();
|
|
|
|
|
TreeItem root = mTree.getRoot();
|
|
|
|
|
for (Module md : mds) {
|
|
|
|
|
TreeItem<String> treeItem = new TreeItem<>(md.getModuleName());
|
|
|
|
|
treeItem.setExpanded(true);
|
|
|
|
|