-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
234 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/main/java/com/zzg/mybatis/generator/controller/GeneratorConfigController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.zzg.mybatis.generator.controller; | ||
|
||
import com.zzg.mybatis.generator.model.GeneratorConfig; | ||
import com.zzg.mybatis.generator.util.ConfigHelper; | ||
import com.zzg.mybatis.generator.view.AlertUtil; | ||
import javafx.collections.FXCollections; | ||
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.layout.HBox; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.net.URL; | ||
import java.util.List; | ||
import java.util.ResourceBundle; | ||
|
||
/** | ||
* Created by Owen on 8/21/16. | ||
*/ | ||
public class GeneratorConfigController extends BaseFXController { | ||
|
||
private static final Logger _LOG = LoggerFactory.getLogger(GeneratorConfigController.class); | ||
|
||
@FXML | ||
private TableView<GeneratorConfig> configTable; | ||
@FXML | ||
private TableColumn nameColumn; | ||
@FXML | ||
private TableColumn opsColumn; | ||
|
||
private MainUIController mainUIController; | ||
|
||
private GeneratorConfigController controller; | ||
|
||
@Override | ||
public void initialize(URL location, ResourceBundle resources) { | ||
controller = this; | ||
nameColumn.setCellValueFactory(new PropertyValueFactory<>("name")); | ||
// 自定义操作列 | ||
opsColumn.setCellValueFactory(new PropertyValueFactory<>("name")); | ||
opsColumn.setCellFactory(cell -> { | ||
return new TableCell() { | ||
@Override | ||
protected void updateItem(Object item, boolean empty) { | ||
super.updateItem(item, empty); | ||
if (item == null || empty) { | ||
setText(null); | ||
} else { | ||
Button btn1 = new Button("应用"); | ||
Button btn2 = new Button("删除"); | ||
HBox hBox = new HBox(); | ||
hBox.setSpacing(10); | ||
hBox.getChildren().add(btn1); | ||
hBox.getChildren().add(btn2); | ||
btn1.setOnAction(event -> { | ||
try { | ||
// 应用配置 | ||
GeneratorConfig generatorConfig = ConfigHelper.loadGeneratorConfig(item.toString()); | ||
mainUIController.setGeneratorConfigIntoUI(generatorConfig); | ||
controller.closeDialogStage(); | ||
} catch (Exception e) { | ||
AlertUtil.showErrorAlert(e.getMessage()); | ||
} | ||
}); | ||
btn2.setOnAction(event -> { | ||
try { | ||
// 删除配置 | ||
_LOG.debug("item: {}", item); | ||
ConfigHelper.deleteGeneratorConfig(item.toString()); | ||
refreshTableView(); | ||
} catch (Exception e) { | ||
AlertUtil.showErrorAlert(e.getMessage()); | ||
} | ||
}); | ||
setGraphic(hBox); | ||
} | ||
} | ||
}; | ||
}); | ||
refreshTableView(); | ||
} | ||
|
||
public void refreshTableView() { | ||
try { | ||
List<GeneratorConfig> configs = ConfigHelper.loadGeneratorConfigs(); | ||
configTable.setItems(FXCollections.observableList(configs)); | ||
} catch (Exception e) { | ||
AlertUtil.showErrorAlert(e.getMessage()); | ||
} | ||
} | ||
|
||
void setMainUIController(MainUIController mainUIController) { | ||
this.mainUIController = mainUIController; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.