diff --git a/README_ZH.md b/README_ZH.md index 27a15a9c4a6187d418fb9949141135cef60e010d..779f382786e86509b56b2e96aefd33014ac2ff25 100755 --- a/README_ZH.md +++ b/README_ZH.md @@ -5,7 +5,7 @@ 更多工具的架构和实现原理详情,可以左键单击以下链接了解: -[工具使用说明](https://gitee.com/openharmony-sig/napi_generator/blob/master/docs/INSTRUCTION_ZH.md) +[工具使用说明](https://gitee.com/openharmony/napi_generator/blob/master/docs/INSTRUCTION_ZH.md) ## 目录 @@ -56,7 +56,7 @@ napi_generator/ prebuilt 具体的工具使用步骤,可以左键单击以下链接了解: -[工具使用说明](https://gitee.com/openharmony-sig/napi_generator/blob/master/docs/INSTRUCTION_ZH.md) +[工具使用说明](https://gitee.com/openharmony/napi_generator/blob/master/docs/INSTRUCTION_ZH.md) ### 工具输出 @@ -101,7 +101,7 @@ bool TestClass1::if_callback(std::string &v1, std::string &out) { 把工具的生成代码集成到OpenHarmony的具体操作步骤,可以左键单击以下链接了解: -[生成代码集成到OpenHarmony的方法](https://gitee.com/openharmony-sig/napi_generator/blob/master/docs/ENSEMBLE_METHOD_ZH.md) +[生成代码集成到OpenHarmony的方法](https://gitee.com/openharmony/napi_generator/blob/master/docs/ENSEMBLE_METHOD_ZH.md) ## 工具开发说明 @@ -117,20 +117,20 @@ bool TestClass1::if_callback(std::string &v1, std::string &out) { 开发者可以根据如下的步骤来完成对工具的开发: - [工具开发说明](https://gitee.com/openharmony-sig/napi_generator/blob/master/docs/DEVELOP_ZH.md) + [工具开发说明](https://gitee.com/openharmony/napi_generator/blob/master/docs/DEVELOP_ZH.md) ## 版本说明 当前版本已支持的特性和代开发的特性,如下所示: - [已支持特性](https://gitee.com/openharmony-sig/napi_generator/blob/master/release-notes/napi_generator-1.0.md) + [已支持特性](https://gitee.com/openharmony/napi_generator/blob/master/release-notes/napi_generator-1.0.md) - [待支持特性](https://gitee.com/openharmony-sig/napi_generator/blob/master/docs/ROADMAP_ZH.md) + [待支持特性](https://gitee.com/openharmony/napi_generator/blob/master/docs/ROADMAP_ZH.md) ## FAQ 对于常见问题解决方法指导如下: - [FAQ](https://gitee.com/openharmony-sig/napi_generator/blob/master/FAQ.md) + [FAQ](https://gitee.com/openharmony/napi_generator/blob/master/FAQ.md) ## 参与贡献 diff --git a/docs/DEVELOP_ZH.md b/docs/DEVELOP_ZH.md index 1e03f4276397b5a266fc3fb6e1b08b0f742b5c30..81b8480cdf63805fa1ec4821289adb5e3222644b 100755 --- a/docs/DEVELOP_ZH.md +++ b/docs/DEVELOP_ZH.md @@ -100,7 +100,7 @@ ## 工具测试 进行工具二次开发后,本地可进行单元测试、story特性测试确保工具的可用性。左键单击以下链接了解详情: - [单元测试](https://gitee.com/openharmony-sig/napi_generator/blob/master/test/unittest/README_ZH%20.md) + [单元测试](https://gitee.com/openharmony/napi_generator/blob/master/test/unittest/README_ZH%20.md) - [story测试](https://gitee.com/openharmony-sig/napi_generator/blob/master/test/storytest/README_ZH.md) + [story测试](https://gitee.com/openharmony/napi_generator/blob/master/test/storytest/README_ZH.md) diff --git a/docs/INSTRUCTION_ZH.md b/docs/INSTRUCTION_ZH.md index 30349bbd4d0b53979f8733af21b333050539f396..007b7a8621b75a6df4bd9895dbca50aec7f35831 100755 --- a/docs/INSTRUCTION_ZH.md +++ b/docs/INSTRUCTION_ZH.md @@ -189,5 +189,5 @@ File->New->Project。 ## 集成测试 NAPI框架代码生成后,系统框架开发者进行二次开发后,即可集成到OpenHarmony编译系统,生成对应的库文件,供应用开发者调用接口。工具集成测试的具体操作步骤可以左键单击以下链接了解: - [工具集成测试](https://gitee.com/openharmony-sig/napi_generator/blob/master/docs/INTEGRATION_TESTING_ZH.md) + [工具集成测试](https://gitee.com/openharmony/napi_generator/blob/master/docs/INTEGRATION_TESTING_ZH.md) diff --git a/docs/INTEGRATION_TESTING_ZH.md b/docs/INTEGRATION_TESTING_ZH.md index 68ab39a4c39a53303d214a0bb423bd61ecd68133..1214e09088f20291fb40cc0b141be5f158851a86 100755 --- a/docs/INTEGRATION_TESTING_ZH.md +++ b/docs/INTEGRATION_TESTING_ZH.md @@ -11,7 +11,7 @@ 系统镜像的具体生成方法,可以左键单击以下链接了解: - [生成代码集成到OpenHarmony的方法](https://gitee.com/openharmony-sig/napi_generator/blob/master/docs/ENSEMBLE_METHOD_ZH.md) + [生成代码集成到OpenHarmony的方法](https://gitee.com/openharmony/napi_generator/blob/master/docs/ENSEMBLE_METHOD_ZH.md) 3.应用hap包:hap包及源码路径如下: diff --git a/release-notes/napi_generator-1.0.md b/release-notes/napi_generator-1.0.md index 2e2e2a019c4990e6e0f470d8f3d4b9b0eb0359b8..9accf94235c51210d7e062d61635624c512e2897 100644 --- a/release-notes/napi_generator-1.0.md +++ b/release-notes/napi_generator-1.0.md @@ -49,5 +49,5 @@ **表 2** -[待开发特性](https://gitee.com/openharmony-sig/napi_generator/blob/master/docs/ROADMAP_ZH.md) +[待开发特性](https://gitee.com/openharmony/napi_generator/blob/master/docs/ROADMAP_ZH.md) diff --git a/src/generator/src/com/sk/dialog/ErrorDialog.java b/src/generator/src/com/sk/dialog/ErrorDialog.java index dedec284f5cb36a198031f81d9a7bd49aa718eb0..7cb4259bf792a86ed3ad589c933fda58eb02e7ba 100644 --- a/src/generator/src/com/sk/dialog/ErrorDialog.java +++ b/src/generator/src/com/sk/dialog/ErrorDialog.java @@ -17,7 +17,9 @@ package com.sk.dialog; import com.intellij.openapi.diagnostic.Logger; import javax.swing.*; -import java.awt.event.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.io.IOException; /** @@ -33,37 +35,30 @@ public class ErrorDialog extends JDialog { private JTextArea textAreaError; public ErrorDialog(String sErrorMessage) { + initDialog(sErrorMessage); + } + + private void initDialog(String sErrorMessage) { setContentPane(contentPane); setModal(true); - getRootPane().setDefaultButton(buttonOK); setTitle("执行失败"); textAreaError.setText(sErrorMessage); - buttonOK.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - onOK(); - } - }); + buttonOK.addActionListener(e -> onOK()); - buttonHelp.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - onCancel(); - } - }); + buttonHelp.addActionListener(e -> onCancel()); - // call onCancel() when cross is clicked setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { + @Override public void windowClosing(WindowEvent e) { onCancel(); } + }); // call onCancel() on ESCAPE - contentPane.registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - onCancel(); - } - }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + contentPane.registerKeyboardAction(e -> onCancel(), + KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); } private void onOK() { @@ -72,10 +67,10 @@ public class ErrorDialog extends JDialog { private void onCancel() { try { - Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler" + - " https://gitee.com/openharmony-sig/napi_generator"); + Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler" + + " https://gitee.com/openharmony-sig/napi_generator"); } catch (IOException e) { - LOG.error("exec command help error"); + LOG.error("exec command help error" + e.getMessage()); } dispose(); } diff --git a/src/generator/src/com/sk/dialog/GenResultDialog.java b/src/generator/src/com/sk/dialog/GenResultDialog.java index f2b51410c8e73414f33a3eba48054e264e316a8c..799242d607fe992b87f52b57b38ce227cb6ead04 100644 --- a/src/generator/src/com/sk/dialog/GenResultDialog.java +++ b/src/generator/src/com/sk/dialog/GenResultDialog.java @@ -17,8 +17,6 @@ package com.sk.dialog; import com.intellij.openapi.diagnostic.Logger; import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -39,11 +37,7 @@ public class GenResultDialog extends JDialog { setModal(true); getRootPane().setDefaultButton(buttonOK); setTitle("执行成功"); - buttonOK.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - onOK(); - } - }); + buttonOK.addActionListener(e -> onOK()); List fileList = getDirFileName(directoryPath); resultList.setListData(fileList.toArray(new String[fileList.size()])); } diff --git a/src/generator/src/com/sk/dialog/GenerateDialog.java b/src/generator/src/com/sk/dialog/GenerateDialog.java index e33eb4876efc39fc578a617b05e34496933309d6..fc5bb17afa6ad4ce6119f54a9b3b5d6e52afad57 100644 --- a/src/generator/src/com/sk/dialog/GenerateDialog.java +++ b/src/generator/src/com/sk/dialog/GenerateDialog.java @@ -22,7 +22,10 @@ import com.sk.utils.FileUtil; import org.apache.http.util.TextUtils; import javax.swing.*; -import java.awt.event.*; +import java.awt.event.ComponentAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.io.*; /** @@ -33,6 +36,8 @@ import java.io.*; public class GenerateDialog extends JDialog { private static final Logger LOG = Logger.getInstance(GenerateDialog.class); private static final String TITLE = "Generate Napi Frame"; + private static final String CPP = "add_library(napitest SHARED x_napi_tool.cpp napitest.cpp napitest_middle.cpp)"; + private static final String so = "target_link_libraries(napitest libace_napi.z.so)"; private JPanel contentPane; private JButton buttonOK; private JButton buttonCancel; @@ -58,51 +63,37 @@ public class GenerateDialog extends JDialog { setContentPane(contentPane); setModal(true); setTitle(TITLE); - getRootPane().setDefaultButton(buttonOK); - buttonOK.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - onOK(); - } - }); + buttonOK.addActionListener(e -> onOK()); - buttonCancel.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - onCancel(); - } - }); + buttonCancel.addActionListener(e -> onCancel()); // call onCancel() when cross is clicked setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { + @Override public void windowClosing(WindowEvent e) { onCancel(); } }); // call onCancel() on ESCAPE - contentPane.registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - onCancel(); - } - }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + contentPane.registerKeyboardAction(e -> onCancel(), + KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); selectInter.addActionListener(new BrowseAction(selectInter, textField1)); selectGenPath.addActionListener(new GenAction(selectGenPath, textField2)); select.addActionListener(new ScriptAction(select, textField3)); buttonHelp.addComponentListener(new ComponentAdapter() { }); - buttonHelp.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - onHelp(); - } - }); + buttonHelp.addActionListener(e -> onHelp()); } private void onHelp() { try { - Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler" + " https://gitee.com/openharmony-sig/napi_generator"); + Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler" + + " https://gitee.com/openharmony-sig/napi_generator"); } catch (IOException e) { - LOG.error("exec command help error"); + LOG.error("exec command help error" + e.getMessage()); } dispose(); } @@ -111,6 +102,9 @@ public class GenerateDialog extends JDialog { textField1.setText(destPath); textField2.setText(directoryPath); textField3.setText(directoryPath); + btnGenPath.setText("生成框架路径:"); + btnSelectScript.setText("编译脚本路径:"); + btnSelectInter.setText("接口文件:"); } private void onOK() { @@ -156,11 +150,11 @@ public class GenerateDialog extends JDialog { try { callExtProcess(command); } catch (InterruptedException e) { - LOG.warn("exec command Interrupted"); + LOG.warn("exec command Interrupted" + e.getMessage()); Thread.currentThread().interrupt(); } } catch (IOException ex) { - LOG.debug("exec command error"); + LOG.debug("exec command error" + ex.getMessage()); } } @@ -178,7 +172,7 @@ public class GenerateDialog extends JDialog { byte[] bs = inputStream.readAllBytes(); writeTmpFile(execFn, bs); } catch (IOException e) { - LOG.error("runFun WIN write_tmp_file io error"); + LOG.error("runFun WIN write_tmp_file io error" + e.getMessage()); } } return file + " " + "-f" + " " + destPath + " " + "-o" + " " + parentPath; @@ -206,7 +200,7 @@ public class GenerateDialog extends JDialog { } private void writeCommand() { - String command = "add_library(napitest SHARED x_napi_tool.cpp napitest.cpp napitest_middle.cpp)".replaceAll("napitest", fileName) + "\n" + "target_link_libraries(napitest libace_napi.z.so)".replaceAll("napitest", fileName); + String command = CPP.replaceAll("napitest", fileName) + "\n" + so.replaceAll("napitest", fileName); FileUtil fileUtil = new FileUtil(); String filePath = fileUtil.makeFile(directoryPath + "/makeFile.txt"); if (TextUtils.isEmpty(filePath)) { @@ -237,16 +231,10 @@ public class GenerateDialog extends JDialog { LOG.info("writeTmpFile createNewFile error"); } } - FileOutputStream fw = null; - try { - fw = new FileOutputStream(file); + try (FileOutputStream fw = new FileOutputStream(file)) { fw.write(bs, 0, bs.length); } catch (IOException e) { - LOG.error("writeTmpFile io error"); - } finally { - if (fw != null) { - fw.close(); - } + LOG.error("writeTmpFile io error" + e.getMessage()); } } @@ -288,7 +276,7 @@ public class GenerateDialog extends JDialog { } sErr += sTmp + "\n"; } catch (IOException e) { - LOG.error(" genResultLog stdInput error"); + LOG.error(" genResultLog stdInput error" + e.getMessage()); } } return sErr; @@ -313,7 +301,7 @@ public class GenerateDialog extends JDialog { } sOut += sTmp + "\n"; } catch (IOException e) { - LOG.error(" genResultLog stdInput error"); + LOG.error(" genResultLog stdInput error" + e.getMessage()); } } return sOut; @@ -337,7 +325,7 @@ public class GenerateDialog extends JDialog { LOG.error("StreamConsumer" + line); } } catch (IOException ex) { - LOG.error("StreamConsumer io error"); + LOG.error("StreamConsumer io error" + ex.getMessage()); } } }