diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/AndroidOptionController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/AndroidOptionController.java new file mode 100644 index 00000000..24a7eaec --- /dev/null +++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/AndroidOptionController.java @@ -0,0 +1,79 @@ +package xyz.wbsite.dbtool.javafx.ctrl; + +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TextField; + +public class AndroidOptionController { + + @FXML + private TextField path; + @FXML + private Button selectPath; + @FXML + private TextField name; + @FXML + private TextField packages; + @FXML + private TextField domain; + @FXML + private Button ok; + @FXML + private Button cancel; + + public Button getOk() { + return ok; + } + + public void setOk(Button ok) { + this.ok = ok; + } + + public Button getCancel() { + return cancel; + } + + public void setCancel(Button cancel) { + this.cancel = cancel; + } + + public TextField getPath() { + return path; + } + + public void setPath(TextField path) { + this.path = path; + } + + public Button getSelectPath() { + return selectPath; + } + + public void setSelectPath(Button selectPath) { + this.selectPath = selectPath; + } + + public TextField getName() { + return name; + } + + public void setName(TextField name) { + this.name = name; + } + + public TextField getPackages() { + return packages; + } + + public void setPackages(TextField packages) { + this.packages = packages; + } + + public TextField getDomain() { + return domain; + } + + public void setDomain(TextField domain) { + this.domain = domain; + } +} diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java index 613b2f6b..b1ad7edd 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/ctrl/MainController.java @@ -190,4 +190,8 @@ public class MainController { public void generateApi(ActionEvent actionEvent) { Dialog.showApi(); } + @FXML + public void generateAndroid(ActionEvent actionEvent) { + Dialog.showAndroid(); + } } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java index f7386ce5..2ed19428 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/ProjectManager.java @@ -1,5 +1,6 @@ package xyz.wbsite.dbtool.javafx.manger; +import com.sun.org.apache.xpath.internal.operations.And; import org.springframework.boot.system.ApplicationHome; import xyz.wbsite.dbtool.javafx.enumeration.DataBase; import xyz.wbsite.dbtool.javafx.enumeration.FieldType; @@ -281,7 +282,7 @@ public class ProjectManager { } - public void generateSDK(File module, File sdk, List apis) { + public void generateApi(File module, File sdk, List apis) { if (module.exists()) { boolean mkdirs = sdk.mkdirs(); File reqList = new File(module.getAbsolutePath() + File.separator + "req"); @@ -305,6 +306,10 @@ public class ProjectManager { } } + public void generateAndroid(final String path, AndroidOption option){ + + } + public void invalidate() { project = xmlService.inflate(path); } diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/po/AndroidOption.java b/src/main/java/xyz/wbsite/dbtool/javafx/po/AndroidOption.java new file mode 100644 index 00000000..326a3f60 --- /dev/null +++ b/src/main/java/xyz/wbsite/dbtool/javafx/po/AndroidOption.java @@ -0,0 +1,7 @@ +package xyz.wbsite.dbtool.javafx.po; + +public class AndroidOption { + public String projectName; + public String packages; + public String domain; +} diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java b/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java index eab32e9e..e5b19548 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/tool/Dialog.java @@ -1,6 +1,7 @@ package xyz.wbsite.dbtool.javafx.tool; import xyz.wbsite.dbtool.Application; +import xyz.wbsite.dbtool.javafx.ctrl.AndroidOptionController; import xyz.wbsite.dbtool.javafx.ctrl.ConnectInfoController; import xyz.wbsite.dbtool.javafx.ctrl.GenerateOptionController; import xyz.wbsite.dbtool.javafx.ctrl.SdkInfoController; @@ -8,6 +9,7 @@ import xyz.wbsite.dbtool.javafx.enumeration.DataBase; import xyz.wbsite.dbtool.javafx.listener.GenerateOptionListener; import xyz.wbsite.dbtool.javafx.manger.ProjectManager; import xyz.wbsite.dbtool.javafx.manger.ManagerFactory; +import xyz.wbsite.dbtool.javafx.po.AndroidOption; import xyz.wbsite.dbtool.javafx.po.Api; import xyz.wbsite.dbtool.javafx.po.Module; import javafx.application.Platform; @@ -350,7 +352,7 @@ public class Dialog { Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); - FXMLLoader dbdetailloader = new FXMLLoader(Application.class.getResource("../../../fxml/api.fxml")); + FXMLLoader dbdetailloader = new FXMLLoader(Application.class.getResource("../../../fxml/apiOption.fxml")); try { dbdetailloader.load(); Parent root = dbdetailloader.getRoot(); @@ -379,7 +381,7 @@ public class Dialog { File api = new File(sdkPath.getText()); - sdkPath.setText(new File(api.getParentFile().getAbsolutePath(),file.getName()+"-api").getAbsolutePath()); + sdkPath.setText(new File(api.getParentFile().getAbsolutePath(), file.getName() + "-api").getAbsolutePath()); System.out.println(file.getAbsolutePath()); @@ -399,7 +401,7 @@ public class Dialog { String text = modulePath.getText(); File moduleFile = new File(text); - sdkPath.setText(new File(file.getAbsolutePath(),moduleFile.getName()+"-api").getAbsolutePath()); + sdkPath.setText(new File(file.getAbsolutePath(), moduleFile.getName() + "-api").getAbsolutePath()); System.out.println(file.getAbsolutePath()); } }); @@ -481,7 +483,7 @@ public class Dialog { sdkPath.setText(""); } else { modulePath.setText(modul.getAbsolutePath()); - sdkPath.setText(new File(f.getParentFile().getAbsolutePath(),modul.getName() + "-api").getAbsolutePath()); + sdkPath.setText(new File(f.getParentFile().getAbsolutePath(), modul.getName() + "-api").getAbsolutePath()); break s; } @@ -497,7 +499,7 @@ public class Dialog { if (new File(module).exists()) { Dialog.showProgress("生成中..."); - dBmanger.generateSDK(new File(module), new File(sdk), controller.getData()); + dBmanger.generateApi(new File(module), new File(sdk), controller.getData()); Dialog.stopPopup(); Platform.runLater(new Runnable() { @Override @@ -525,6 +527,75 @@ public class Dialog { } } + public static void showAndroid() { + FXMLLoader dbdetailloader = new FXMLLoader(Application.class.getResource("../../../fxml/androidOption.fxml")); + try { + dbdetailloader.load(); + } catch (IOException e) { + e.printStackTrace(); + return; + } + Parent root = dbdetailloader.getRoot(); + AndroidOptionController controller = dbdetailloader.getController(); + controller.getCancel().setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent event) { + stopPopup(); + } + }); + controller.getOk().setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent event) { + ProjectManager dBmanger = ManagerFactory.getdBManager(); + DirectoryChooser directoryChooser = new DirectoryChooser(); + directoryChooser.setInitialDirectory(new File(dBmanger.getPath())); + Stage stage = new Stage(); + File file = directoryChooser.showDialog(stage); + + System.out.println("生成目录:" + file.getAbsolutePath()); + AndroidOption androidOption = new AndroidOption(); + androidOption.projectName = controller.getName().getText(); + androidOption.packages = controller.getPackages().getText(); + androidOption.domain = controller.getDomain().getText(); + dBmanger.generateAndroid(file.getAbsolutePath(), androidOption); + } + }); + TextField path = controller.getPath(); + controller.getSelectPath().setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent event) { + DirectoryChooser directoryChooser = new DirectoryChooser(); + Stage stage = new Stage(); + File file = directoryChooser.showDialog(stage); + + if (file == null) { + return; + } + + path.setText(file.getAbsolutePath()); + System.out.println(file.getAbsolutePath()); + } + }); + + ProjectManager dBmanger = ManagerFactory.getdBManager(); + path.setText(dBmanger.getPath()); + + popup = new Stage(); + popup.initModality(Modality.APPLICATION_MODAL); + + Scene scene = new Scene(root); + + popup.setOnCloseRequest(new EventHandler() { + @Override + public void handle(WindowEvent event) { + stopPopup(); + } + }); + popup.setScene(scene); + popup.setTitle("配置"); + popup.show(); + } + private static void check(SdkInfoController controller, boolean check, String key) { for (Api api : controller.getData()) { if (api.getMethod().endsWith(key) || (key.equals(".api.") && api.getMethod().contains(".api."))) { diff --git a/src/main/resources/fxml/androidOption.fxml b/src/main/resources/fxml/androidOption.fxml new file mode 100644 index 00000000..e70580b8 --- /dev/null +++ b/src/main/resources/fxml/androidOption.fxml @@ -0,0 +1,48 @@ + + + + + +
+ + + + + + + + + + + + + +
+ + + +