diff --git a/napi_IntelliJ_plugin/resources/images/openDisk.png b/napi_IntelliJ_plugin/resources/images/openDisk.png index 5e66baa62e361484a32069b4277e269bcdce722f..5956a0e538a400c7deaf41167ae5ea70348b8584 100644 Binary files a/napi_IntelliJ_plugin/resources/images/openDisk.png and b/napi_IntelliJ_plugin/resources/images/openDisk.png differ diff --git a/napi_IntelliJ_plugin/resources/images/text.png b/napi_IntelliJ_plugin/resources/images/text.png index e2442e2b179f2069f6345e8bbff808c3e6b0bb05..f42534169aa41dd830a7cb09792fe1428c2f34f7 100644 Binary files a/napi_IntelliJ_plugin/resources/images/text.png and b/napi_IntelliJ_plugin/resources/images/text.png differ diff --git a/napi_IntelliJ_plugin/src/com/sk/action/SelectHAction.java b/napi_IntelliJ_plugin/src/com/sk/action/SelectHAction.java new file mode 100644 index 0000000000000000000000000000000000000000..ea441d79c663d73437e63bc1d70f3bc95c07bbbd --- /dev/null +++ b/napi_IntelliJ_plugin/src/com/sk/action/SelectHAction.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sk.action; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JTextField; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * 编译文件夹选择框 + * + * @author: xudong + * @see: select generator file path + * @version: v1.0.0 + * @since 2022-02-21 + */ +public class SelectHAction implements ActionListener { + private final JButton button; + private final JTextField textField; + + public SelectHAction(JButton button, JTextField textField) { + this.button = button; + this.textField = textField; + } + + @Override + public void actionPerformed(ActionEvent actionEvent) { + if (actionEvent.getSource().equals(button)) { + JFileChooser fcDlg = new JFileChooser(textField.getText()); + fcDlg.setDialogTitle("请选择.h文件路径..."); + fcDlg.setFileSelectionMode(JFileChooser.FILES_ONLY); + FileNameExtensionFilter filter = new FileNameExtensionFilter("文本文件(*.h)", "h"); + fcDlg.setMultiSelectionEnabled(true); + fcDlg.setFileFilter(filter); + int returnVal = fcDlg.showOpenDialog(null); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String filepath = fcDlg.getSelectedFile().getPath(); + textField.setText(filepath); + } + } + } +} diff --git a/napi_IntelliJ_plugin/src/com/sk/action/SelectOutPathAction.java b/napi_IntelliJ_plugin/src/com/sk/action/SelectOutPathAction.java new file mode 100644 index 0000000000000000000000000000000000000000..e1dfad103dd9ace40ab46dd425956ecded5ece1b --- /dev/null +++ b/napi_IntelliJ_plugin/src/com/sk/action/SelectOutPathAction.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.sk.action; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JTextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * 编译文件夹选择框 + * + * @author: xudong + * @see: select generator file path + * @version: v1.0.0 + * @since 2022-02-21 + */ +public class SelectOutPathAction implements ActionListener { + private final JButton button; + private final JTextField textField; + + public SelectOutPathAction(JButton button, JTextField textField) { + this.button = button; + this.textField = textField; + } + + @Override + public void actionPerformed(ActionEvent actionEvent) { + if (actionEvent.getSource().equals(button)) { + JFileChooser fcDlg = new JFileChooser(textField.getText()); + fcDlg.setDialogTitle("请选择输出目录路径..."); + fcDlg.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int returnVal = fcDlg.showOpenDialog(null); + if (returnVal == JFileChooser.APPROVE_OPTION) { + String filepath = fcDlg.getSelectedFile().getPath(); + textField.setText(filepath); + } + } + } +} diff --git a/napi_IntelliJ_plugin/src/com/sk/dialog/ConfirmDialog.java b/napi_IntelliJ_plugin/src/com/sk/dialog/ConfirmDialog.java index 7bcf2479d57018d721bd90978f09892362c3ddf4..33d1fe630bda2d2bfc33eecbf48b29a5174c50e0 100644 --- a/napi_IntelliJ_plugin/src/com/sk/dialog/ConfirmDialog.java +++ b/napi_IntelliJ_plugin/src/com/sk/dialog/ConfirmDialog.java @@ -22,7 +22,7 @@ import javax.swing.JComponent; /** * 自定义确认对话框Wrapper * - * @author: liulongc digitalchina.com + * @author: xudong * @see: tool conversion plug-in * @version: v1.0.0 * @since 2022-02-21 diff --git a/napi_IntelliJ_plugin/src/com/sk/dialog/GenerateDialog.java b/napi_IntelliJ_plugin/src/com/sk/dialog/GenerateDialog.java index 0a3cfdd54cde729cae22023eccdd62f3a53ca7ed..4c35250db86237fe16c659c1a11b1a558fa5bfd2 100644 --- a/napi_IntelliJ_plugin/src/com/sk/dialog/GenerateDialog.java +++ b/napi_IntelliJ_plugin/src/com/sk/dialog/GenerateDialog.java @@ -21,8 +21,9 @@ import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.ValidationInfo; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.swing.JComponent; + import javax.swing.Action; +import javax.swing.JComponent; import java.awt.Desktop; import java.awt.event.ActionEvent; import java.io.IOException; @@ -32,30 +33,30 @@ import java.net.URISyntaxException; /** * 主界面对话框Wrapper * - * @author: liulongc digitalchina.com + * @author: xudong * @see: tool conversion plug-in * @version: v1.0.0 * @since 2022-05-27 */ public class GenerateDialog extends DialogWrapper { private static final Logger LOG = Logger.getInstance(GenerateDialog.class); - private static final String TITLE = "Generate Napi Frame"; - private static final String URL = "https://gitee.com/openharmony/napi_generator"; + private static final String FRAME_TITLE = "Generate Napi Frame"; + private static final String CODE_URL = "https://gitee.com/openharmony/napi_generator"; private final GenerateDialogPane genDiag; /** * 构造函数 * - * @param project projectid - * @param destPath 目录文件 + * @param project projectId + * @param destPath 目录文件 * @param directoryPath 文件夹目录 - * @param fileName 文件名 + * @param fileName 文件名 */ public GenerateDialog(Project project, String destPath, String directoryPath, String fileName) { super(true); this.setResizable(false); - setTitle(TITLE); + setTitle(FRAME_TITLE); setModal(true); genDiag = new GenerateDialogPane(project, destPath, directoryPath, fileName); init(); @@ -124,8 +125,14 @@ public class GenerateDialog extends DialogWrapper { if (validationInfo != null) { LOG.info(validationInfo.message); } else { - if (genDiag.runFun()) { - close(CANCEL_EXIT_CODE); + if (genDiag.getSelectedIndex() == 0) { + if (genDiag.runFun()) { + close(CANCEL_EXIT_CODE); + } + } else { + if (genDiag.runFunH2ts()) { + close(CANCEL_EXIT_CODE); + } } } } @@ -143,7 +150,7 @@ public class GenerateDialog extends DialogWrapper { @Override protected void doAction(ActionEvent actionEvent) { try { - Desktop.getDesktop().browse(new URI(URL)); + Desktop.getDesktop().browse(new URI(CODE_URL)); } catch (URISyntaxException | IOException e) { LOG.error("Open help error:" + e); } diff --git a/napi_IntelliJ_plugin/src/com/sk/dialog/GenerateDialogPane.form b/napi_IntelliJ_plugin/src/com/sk/dialog/GenerateDialogPane.form index 5ca7577ae1e2f16f8a3dd61c1ad7245cffbdff22..0893f9fabfcd4a3d21215edcb5c48b10da0fd71d 100644 --- a/napi_IntelliJ_plugin/src/com/sk/dialog/GenerateDialogPane.form +++ b/napi_IntelliJ_plugin/src/com/sk/dialog/GenerateDialogPane.form @@ -14,190 +14,282 @@ limitations under the License. -->