diff --git a/hdc/api_scan_IntelliJ_plugin/src/com/kh/scan/action/ScanDirAction.java b/hdc/api_scan_IntelliJ_plugin/src/com/kh/scan/action/ScanDirAction.java index dd04c3cb07822f849a3fb19af5759b72c983dfdf..ec3dbec25d41766d5a9e011276ea953183e85d18 100644 --- a/hdc/api_scan_IntelliJ_plugin/src/com/kh/scan/action/ScanDirAction.java +++ b/hdc/api_scan_IntelliJ_plugin/src/com/kh/scan/action/ScanDirAction.java @@ -32,9 +32,12 @@ public class ScanDirAction implements ActionListener { private final JButton button; private final JTextField textField; - public ScanDirAction(JButton button, JTextField textField) { + private JTextField outScanResultPathTextField; + + public ScanDirAction(JButton button, JTextField textField, JTextField outScanResultPathTextField) { this.button = button; this.textField = textField; + this.outScanResultPathTextField = outScanResultPathTextField; } @Override @@ -47,6 +50,7 @@ public class ScanDirAction implements ActionListener { if (returnVal == JFileChooser.APPROVE_OPTION) { String filepath = fcDlg.getSelectedFile().getPath(); textField.setText(filepath); + outScanResultPathTextField.setText(filepath); } } } diff --git a/hdc/api_scan_IntelliJ_plugin/src/com/kh/scan/dialog/ApiScanDialogPane.java b/hdc/api_scan_IntelliJ_plugin/src/com/kh/scan/dialog/ApiScanDialogPane.java index 3ff7261dd6d3522810ac35182457a23b941b7563..3cf3a69bbd7c838e585cef63838bba6c643e0841 100644 --- a/hdc/api_scan_IntelliJ_plugin/src/com/kh/scan/dialog/ApiScanDialogPane.java +++ b/hdc/api_scan_IntelliJ_plugin/src/com/kh/scan/dialog/ApiScanDialogPane.java @@ -74,7 +74,7 @@ public class ApiScanDialogPane extends JDialog { this.project = project; contentPane.registerKeyboardAction(actionEvent -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - selectScanPath.addActionListener(new ScanDirAction(selectScanPath, scanDirPathTextField)); + selectScanPath.addActionListener(new ScanDirAction(selectScanPath, scanDirPathTextField, outScanResultPathTextField)); outSelectPath.addActionListener(new ScanResultDirAction(outSelectPath, outScanResultPathTextField)); } @@ -142,12 +142,11 @@ public class ApiScanDialogPane extends JDialog { GenNotification.notifyMessage(this.project, "", "正在生成", NotificationType.INFORMATION); scanDir = scanDirPathTextField.getText(); scanResultDir = outScanResultPathTextField.getText(); - copyFileToTmpPath(); String command; command = genCommand(); try { if (!TextUtils.isEmpty(command) && callExtProcess(command)) { - GenNotification.notifyMessage(project, scanDirPathTextField.getText(), "提示", + GenNotification.notifyMessage(project, scanResultDir, "提示", NotificationType.INFORMATION, true); return true; } @@ -168,8 +167,16 @@ public class ApiScanDialogPane extends JDialog { String sysName = System.getProperties().getProperty("os.name").toUpperCase(); String tmpDirFile = System.getProperty("java.io.tmpdir"); String execFn; - execFn = "cmds/scan.py"; - tmpDirFile += "scan.py"; + if (sysName.contains("WIN")) { + execFn = "cmds/win/search-win.exe"; + tmpDirFile += "search-win.exe"; + } else if (sysName.contains("LINUX")) { + execFn = "cmds/linux/search-linux"; + tmpDirFile += "/search-linux"; + } else { + execFn = "cmds/mac/search-macos"; + tmpDirFile += "/search-macos"; + } File file = new File(tmpDirFile); try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(execFn)) { if (inputStream == null) { @@ -188,51 +195,45 @@ public class ApiScanDialogPane extends JDialog { return ""; } String command = file.toString(); - command = "python " + command + " " + scanDir; + command = command + " -d " + scanDir + " -o " + scanResultDir; return command; } - private void copyFileToTmpPath() { - String sysName = System.getProperties().getProperty("os.name").toUpperCase(); - String tmpDirFile = System.getProperty("java.io.tmpdir"); - String execFn = "cmds/scan_api.xlsx"; - tmpDirFile += "scan_api.xlsx"; - try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(execFn)) { - if (inputStream == null) { - throw new IOException("exec File InputStream is Null"); - } - byte[] bs = inputStream.readAllBytes(); - writeTmpFile(tmpDirFile, bs); - if (sysName.contains("LINUX") || sysName.contains("MAC OS")) { - executable(tmpDirFile); - } - } catch (IOException | InterruptedException e) { - GenNotification.notifyMessage(this.project, e.getMessage(), "Can not Find File:" + execFn, - NotificationType.ERROR); - LOG.error(e); - } - } - private boolean callExtProcess(String command) throws IOException, InterruptedException { if (TextUtils.isEmpty(command)) { GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR); return false; } - // 安装openpyxl依赖 - Runtime.getRuntime().exec("pip install openpyxl"); String tmpDirFile = System.getProperty("java.io.tmpdir"); - Process process = Runtime.getRuntime().exec(command, null, new File(tmpDirFile)); - genResultLog(process); - StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream()); - StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream()); - errConsumer.start(); - outputConsumer.start(); - if (!generateSuccess) { - GenNotification.notifyMessage(project, sErrorMessage, "提示", NotificationType.ERROR); - return false; + try { + Process process = Runtime.getRuntime().exec(command, null, new File(tmpDirFile)); + new Thread(() -> { + BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); + genResultLog(process); + try { + while (br.readLine() != null) ; + LOG.info(" callExtProcess " + br.readLine()); + } catch (IOException ioException) { + LOG.error(" callExtProcess error" + ioException); + } + }).start(); + genResultLog(process); + StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream()); + StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream()); + errConsumer.start(); + outputConsumer.start(); + if (generateSuccess) { + GenNotification.notifyMessage(project, "执行成功", "提示", NotificationType.INFORMATION); + } else { + GenNotification.notifyMessage(project, sErrorMessage, "提示", NotificationType.ERROR); + return false; + } + errConsumer.join(); + outputConsumer.join(); + process.destroy(); + } catch (Exception exception) { + LOG.error(" callExtProcess error" + exception); } - errConsumer.join(); - outputConsumer.join(); return true; } diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/build.gradle.kts b/hdc/assist_tools_intelliJ_plugin_gradle/build.gradle.kts new file mode 100644 index 0000000000000000000000000000000000000000..925b42e9736782adeb1112d46845bbe912de2a5d --- /dev/null +++ b/hdc/assist_tools_intelliJ_plugin_gradle/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + id("java") + id("org.jetbrains.intellij") version "1.5.2" +} + +group = "com.kh.tools.ng" +version = "1.0" + +repositories { + mavenCentral() +} + +dependencies { + implementation(files("lib/gen_intelliJ_plugin_gradle-1.0.jar")) +} +intellij { + version.set("2021.2") + type.set("IC") // Target IDE Platform + plugins.set(listOf("com.sk.ng:1.0.0", "com.sk.gn:1.0.1")) +} +tasks { + // Set the JVM compatibility versions + withType { + sourceCompatibility = "11" + targetCompatibility = "11" + options.encoding = "UTF-8" + } + + patchPluginXml { + sinceBuild.set("212") + untilBuild.set("222.*") + } + + signPlugin { + certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) + privateKey.set(System.getenv("PRIVATE_KEY")) + password.set(System.getenv("PRIVATE_KEY_PASSWORD")) + } + + publishPlugin { + token.set(System.getenv("PUBLISH_TOKEN")) + } +} + diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/gradle/wrapper/gradle-wrapper.jar b/hdc/assist_tools_intelliJ_plugin_gradle/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..41d9927a4d4fb3f96a785543079b8df6723c946b Binary files /dev/null and b/hdc/assist_tools_intelliJ_plugin_gradle/gradle/wrapper/gradle-wrapper.jar differ diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/gradle/wrapper/gradle-wrapper.properties b/hdc/assist_tools_intelliJ_plugin_gradle/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..41dfb87909a877d96c3af4adccce4c7a301b55a2 --- /dev/null +++ b/hdc/assist_tools_intelliJ_plugin_gradle/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/gradlew b/hdc/assist_tools_intelliJ_plugin_gradle/gradlew new file mode 100644 index 0000000000000000000000000000000000000000..1b6c787337ffb79f0e3cf8b1e9f00f680a959de1 --- /dev/null +++ b/hdc/assist_tools_intelliJ_plugin_gradle/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# 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 +# +# https://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. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/gradlew.bat b/hdc/assist_tools_intelliJ_plugin_gradle/gradlew.bat new file mode 100644 index 0000000000000000000000000000000000000000..107acd32c4e687021ef32db511e8a206129b88ec --- /dev/null +++ b/hdc/assist_tools_intelliJ_plugin_gradle/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/settings.gradle.kts b/hdc/assist_tools_intelliJ_plugin_gradle/settings.gradle.kts new file mode 100644 index 0000000000000000000000000000000000000000..f96f0b73e24dd2891855ca1904aafba909df4163 --- /dev/null +++ b/hdc/assist_tools_intelliJ_plugin_gradle/settings.gradle.kts @@ -0,0 +1,2 @@ +rootProject.name = "assist_tools_intelliJ_plugin_gradle" + diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/dialog/ToolCenterDialog.java b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/dialog/ToolCenterDialog.java new file mode 100644 index 0000000000000000000000000000000000000000..361f39a15b6553a9bc76266c3822e51fb47b06c2 --- /dev/null +++ b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/dialog/ToolCenterDialog.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2022 Guangzhou Digitalchina Information Technology Co., Ltd. + * All rights reserved. + * 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.kh.tools.dialog; + +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.DialogWrapper; +import com.kh.tools.utils.PluginUtils; +import com.sk.dialog.GenerateDialog; +import com.sk.gn.dialog.GenGenerateDialog; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.Action; +import javax.swing.JComponent; +import java.awt.Desktop; +import java.awt.event.ActionEvent; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +/** + * 自定义确认对话框Wrapper + * + * @author: zhaoxudong@kaihong.com + * @see: tool conversion plug-in + * @version: v1.0.0 + * @since 2022-09-10 + */ +public class ToolCenterDialog extends DialogWrapper { + private static final Logger LOG = Logger.getInstance(ToolCenterDialog.class); + private final ToolCenterPanel toolCenterPanel; + private Project project; + + public ToolCenterDialog(Project project) { + super(true); + this.project = project; + toolCenterPanel = new ToolCenterPanel(); + setTitle(PluginUtils.TITLE); + init(); + } + + @Override + @Nullable + protected JComponent createCenterPanel() { + return toolCenterPanel.getContentPanel(); + } + + /** + * ok/cancel按钮 + * + * @return Action[] buttos list + */ + @NotNull + @Override + protected Action[] createActions() { + DialogWrapperExitAction exitAction = new DialogWrapperExitAction("Cancel", CANCEL_EXIT_CODE); + ToolCenterDialog.CustomOKAction okAction = new ToolCenterDialog.CustomOKAction(); + okAction.putValue(DialogWrapper.DEFAULT_ACTION, true); + return new Action[]{exitAction, okAction}; + } + + @NotNull + @Override + protected Action[] createLeftSideActions() { + ToolCenterDialog.CustomHelpAction helpAction = new ToolCenterDialog.CustomHelpAction(); + return new Action[]{helpAction}; + } + + /** + * 自定义 next Action + */ + protected class CustomOKAction extends DialogWrapperAction { + + protected CustomOKAction() { + super("Next"); + } + + @Override + protected void doAction(ActionEvent actionEvent) { + if (toolCenterPanel.isSelectButton().equals("Napi")) { + GenerateDialog generateDialog = new GenerateDialog(project, "", "", ""); + generateDialog.showAndGet(); + } else if (toolCenterPanel.isSelectButton().equals("H2ts")) { + GenerateDialog generateDialog = new GenerateDialog(project, "", "", ""); + generateDialog.showAndGet(); + } else if (toolCenterPanel.isSelectButton().equals("Gn")) { + GenGenerateDialog genGenerateDialog = new GenGenerateDialog(project); + genGenerateDialog.showAndGet(); + } + } + } + + /** + * 自定义 help Action + */ + protected class CustomHelpAction extends DialogWrapperAction { + + protected CustomHelpAction() { + super("Help"); + } + + @Override + protected void doAction(ActionEvent actionEvent) { + try { + Desktop.getDesktop().browse(new URI(PluginUtils.URL)); + } catch (URISyntaxException | IOException e) { + LOG.error("Open help error:" + e); + } + } + } +} diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/dialog/ToolCenterPanel.form b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/dialog/ToolCenterPanel.form new file mode 100644 index 0000000000000000000000000000000000000000..6ba4fe2416581d7ba39348ca4c19d9a9bef61caf --- /dev/null +++ b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/dialog/ToolCenterPanel.form @@ -0,0 +1,280 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/dialog/ToolCenterPanel.java b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/dialog/ToolCenterPanel.java new file mode 100644 index 0000000000000000000000000000000000000000..c07963fa58fa32130539bb4a43aae3f9e763c2c5 --- /dev/null +++ b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/dialog/ToolCenterPanel.java @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2022 Guangzhou Digitalchina Information Technology Co., Ltd. + * All rights reserved. + * 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.kh.tools.dialog; + +import com.kh.tools.utils.PluginUtils; + +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; +import javax.swing.JTextField; +import javax.swing.KeyStroke; +import javax.swing.border.EmptyBorder; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.HashMap; + +/** + * 插件中心 + * + * @author: zhaoxudong@kaihong.com + * @see: tool conversion plug-in + * @version: v1.0.0 + * @since 2022-09-16 + */ +public class ToolCenterPanel extends JDialog { + private JPanel contentPane; + private JPanel searchPanel; + private JTextField searchTextField; + private JTabbedPane tabbedPane; + private JLabel toolSecondNameLabel; + private JLabel toolDescLabel; + private JButton buttonNapi; + private JButton buttonNapiName; + private JButton gnButton; + private JButton buttonGn; + private JButton buttonClose; + private JPanel napiPanel; + private JPanel servicePanel; + private String isSelectButton = "Napi"; + + public ToolCenterPanel() { + tabbedPane.removeTabAt(1); + setContentPane(contentPane); + setModal(true); + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + searchTextField.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + searchPanel.setBorder(PluginUtils.BORDER_FOCUS_GAINED); + if (searchTextField.getText().equals("search")) { + searchTextField.setText(""); + } + } + + @Override + public void focusLost(FocusEvent e) { + searchPanel.setBorder(PluginUtils.BORDER_FOCUS_LOST_SEARCH); + if (searchTextField.getText().trim().length() < 1) { + searchTextField.setText("search"); + } + } + }); + searchTextField.setForeground(Color.white); + searchTextField.setBackground(Color.decode("#3c3f41")); + searchTextField.setBorder(new EmptyBorder(0, 0, 0, 0)); + searchTextField.setCaretColor(Color.white); + searchTextField.setFont(new Font(null, Font.PLAIN, 15)); + setButtonStyle(); + textFieldAction(); + buttonAction(); + } + + private void setButtonStyle() { + buttonClose.setPreferredSize(new Dimension(40, 10)); + buttonClose.setContentAreaFilled(false); + buttonClose.setBorder(new EmptyBorder(0, 0, 0, 0)); + buttonNapiName.setContentAreaFilled(false); + buttonNapiName.setBorder(new EmptyBorder(0, 0, 0, 0)); + gnButton.setContentAreaFilled(false); + gnButton.setBorder(new EmptyBorder(0, 0, 0, 0)); + } + + private void textFieldAction() { + searchTextField.getDocument().addDocumentListener(new DocumentListener() { + HashMap result; + + @Override + public void insertUpdate(DocumentEvent e) { + result = searchTools(searchTextField.getText().trim()); + if (result.containsKey(buttonNapi.getToolTipText())) { + napiPanel.setVisible(true); + } else { + napiPanel.setVisible(false); + } + if (result.containsKey(buttonGn.getToolTipText())) { + servicePanel.setVisible(true); + } else { + servicePanel.setVisible(false); + } + } + + @Override + public void removeUpdate(DocumentEvent e) { + result = searchTools(searchTextField.getText().trim()); + if (result.containsKey(buttonNapi.getToolTipText())) { + napiPanel.setVisible(true); + } else { + napiPanel.setVisible(false); + } + if (result.containsKey(buttonGn.getToolTipText())) { + servicePanel.setVisible(true); + } else { + servicePanel.setVisible(false); + } + } + + @Override + public void changedUpdate(DocumentEvent e) { + } + }); + buttonClose.addActionListener(e -> searchTextField.setText("search")); + } + + private void buttonAction() { + buttonNapi.addActionListener(e -> { + isSelectButton = "Napi"; + toolSecondNameLabel.setText(buttonNapi.getToolTipText()); + toolDescLabel.setText(PluginUtils.TOOLS.get(buttonNapi.getToolTipText())); + buttonNapiName.setForeground(Color.white); + gnButton.setForeground(Color.decode("#BBBBBB")); + }); + buttonGn.addActionListener(e -> { + isSelectButton = "Gn"; + toolSecondNameLabel.setText(buttonGn.getToolTipText()); + toolDescLabel.setText(PluginUtils.TOOLS.get(buttonGn.getToolTipText())); + gnButton.setForeground(Color.white); + buttonNapiName.setForeground(Color.decode("#BBBBBB")); + }); + } + + private void onCancel() { + dispose(); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(1000, 600); + } + + JPanel getContentPanel() { + return contentPane; + } + + public String isSelectButton() { + return isSelectButton; + } + + /** + * 搜索结果 + * + * @param key 关键字 + * @return 搜索结果 + */ + private HashMap searchTools(String key) { + if (key.equals("search")) { + return PluginUtils.TOOLS; + } + HashMap searchResultList = new HashMap<>(); + for (HashMap.Entry entry : PluginUtils.TOOLS.entrySet()) { + if (entry.getKey().contains(key)) { + searchResultList.put(entry.getKey(), entry.getValue()); + } + } + return searchResultList; + } +} diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/ng/AssistCenterMenu.java b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/ng/AssistCenterMenu.java new file mode 100644 index 0000000000000000000000000000000000000000..4c970f57195426fda00de677906f052a702ce482 --- /dev/null +++ b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/ng/AssistCenterMenu.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Guangzhou Digitalchina Information Technology 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.kh.tools.ng; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.project.Project; +import com.kh.tools.dialog.ToolCenterDialog; +import org.jetbrains.annotations.NotNull; + +/** + * 工具菜单入口 + * + * @author: zhaoxudong@kaihong.com + * @see: tool conversion plug-in + * @version: v1.0.0 + * @since 2022-09-19 + */ +public class AssistCenterMenu extends AnAction { + + @Override + public void actionPerformed(@NotNull AnActionEvent anActionEvent) { + Project project = anActionEvent.getProject(); + + if (project == null) { + return; + } + ToolCenterDialog wrapper = new ToolCenterDialog(project); + wrapper.showAndGet(); + } +} diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/utils/PluginUtils.java b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/utils/PluginUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..c76317698b6a303efa40790dddedb59af2774f4f --- /dev/null +++ b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/java/com/kh/tools/utils/PluginUtils.java @@ -0,0 +1,40 @@ +/* + * 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.kh.tools.utils; + +import javax.swing.BorderFactory; +import javax.swing.border.Border; +import java.awt.Color; +import java.util.HashMap; + +/** + * 工具类 + * + * @author: zhaoxudong@kaihong.com + * @see: tool conversion plug-in + * @version: v1.0.0 + * @since 2022-09-19 + */ +public class PluginUtils { + public static final String URL = "https://gitee.com/openharmony/napi_generator"; + public static final String TITLE = "App dev Tools"; + public static final Border BORDER_FOCUS_GAINED = BorderFactory.createLineBorder(Color.decode("#385584"), 2); + public static final Border BORDER_FOCUS_LOST_SEARCH = BorderFactory.createLineBorder(Color.decode("#646567"), 2); + public static HashMap TOOLS = new HashMap() {{ + put("NAPI Generator", "NAPI tool generates NAPI framework code by typescript file."); + put("Gn Generator", "The Gn generation tool generates gn scripts by other script type files, or perform " + + "reverse conversion."); + }}; +} diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/META-INF/plugin.xml b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/META-INF/plugin.xml new file mode 100644 index 0000000000000000000000000000000000000000..570daa1f471976dc1c2b99a903442f57e93dcd61 --- /dev/null +++ b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/META-INF/plugin.xml @@ -0,0 +1,29 @@ + + com.kh.tools.ng + Assist Tools + 1.0 + 深圳开鸿数字产业发展有限公司 + + + + com.intellij.modules.lang + com.sk.ng + com.sk.gn + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/META-INF/pluginIcon.svg b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/META-INF/pluginIcon.svg new file mode 100644 index 0000000000000000000000000000000000000000..b202c95b9147180fece70b30962088049352f829 --- /dev/null +++ b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/META-INF/pluginIcon.svg @@ -0,0 +1,19 @@ + + + + + + + + + \ No newline at end of file diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/close.png b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/close.png new file mode 100644 index 0000000000000000000000000000000000000000..32edfa363b1a1f764fade91a3a80fc7f626a0315 Binary files /dev/null and b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/close.png differ diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/cloudic_manager.png b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/cloudic_manager.png new file mode 100644 index 0000000000000000000000000000000000000000..5764627e6afb5383806b62f945bc47a1459d4ddc Binary files /dev/null and b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/cloudic_manager.png differ diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/gn.png b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/gn.png new file mode 100644 index 0000000000000000000000000000000000000000..1b4acbe9c4839288088c763afb906497c4d34621 Binary files /dev/null and b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/gn.png differ diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/napi.png b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/napi.png new file mode 100644 index 0000000000000000000000000000000000000000..81d5e40a6e854c85d789eb33f75f7fec3213b62a Binary files /dev/null and b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/napi.png differ diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/search.png b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/search.png new file mode 100644 index 0000000000000000000000000000000000000000..b27fc24d3502eed6f9ac7315d85f01c364009338 Binary files /dev/null and b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/search.png differ diff --git a/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/tools_center.png b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/tools_center.png new file mode 100644 index 0000000000000000000000000000000000000000..e17aac374806516f7d253811de4096544fd5ce85 Binary files /dev/null and b/hdc/assist_tools_intelliJ_plugin_gradle/src/main/resources/images/tools_center.png differ diff --git a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/InputScriptAction.java b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/InputScriptAction.java index a8f157f5ecf14c102b870ce31ba63e99299f208c..bcaf9852a789b0e1135da03670c444d2955bf630 100644 --- a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/InputScriptAction.java +++ b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/InputScriptAction.java @@ -31,6 +31,8 @@ import java.io.File; * @since 2022-09-21 */ public class InputScriptAction implements ActionListener { + private static final String SYS_NAME = System.getProperties().getProperty("os.name").toUpperCase(); + private final JButton button; private final JTextField textField; private final JComboBox comboBox; @@ -54,17 +56,22 @@ public class InputScriptAction implements ActionListener { String filepath = fcDlg.getSelectedFile().getPath(); if (filepath.contains(File.separator)) { textField.setText(filepath.substring(filepath.lastIndexOf("third_party"))); - transplantTextField.setText(filepath.substring(filepath.lastIndexOf("/"))); + String parentFilePath = fcDlg.getSelectedFile().getParent(); + if (SYS_NAME.contains("WIN")) { + transplantTextField.setText(parentFilePath.substring(parentFilePath.lastIndexOf("\\"))); + } else { + transplantTextField.setText(filepath.substring(filepath.lastIndexOf("/"))); + } } else { textField.setText(filepath); transplantTextField.setText(filepath); } - if (filepath.contains("Makefile")) { + if (filepath.contains("CMake")) { + comboBox.setSelectedIndex(1); + } else if (filepath.contains("Make")) { comboBox.setSelectedIndex(0); - } else if (filepath.contains("scons")) { - comboBox.setSelectedIndex(2); } else { - comboBox.setSelectedIndex(1); + comboBox.setSelectedIndex(2); } } } diff --git a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/SelectOriginCodeAction.java b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/SelectOriginCodeAction.java index 453873e482843e981d4d234a211f6ce220abf9c7..affb62760a1704d0c5c1185ccde393a0cd3a6da1 100644 --- a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/SelectOriginCodeAction.java +++ b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/SelectOriginCodeAction.java @@ -31,10 +31,12 @@ import java.awt.event.ActionListener; public class SelectOriginCodeAction implements ActionListener { private final JButton button; private final JTextField textField; + private final JTextField opOutPathTextField; - public SelectOriginCodeAction(JButton button, JTextField textField) { + public SelectOriginCodeAction(JButton button, JTextField textField, JTextField opOutPathTextField) { this.button = button; this.textField = textField; + this.opOutPathTextField = opOutPathTextField; } @Override diff --git a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/SelectOutDirAction.java b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/SelectOutDirAction.java index e4719062ad5ef43c2d0946d4b3cf59e8459cff5e..8bea20138a19d30e54fbe304ea509b99f087ebde 100644 --- a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/SelectOutDirAction.java +++ b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/action/SelectOutDirAction.java @@ -34,6 +34,7 @@ public class SelectOutDirAction implements ActionListener { private final JButton button; private final JTextField textField; + private SelectPathInterface selectPathInterface; /** * 构造函数 @@ -41,9 +42,10 @@ public class SelectOutDirAction implements ActionListener { * @param button 按钮 * @param textField 输入框 */ - public SelectOutDirAction(JButton button, JTextField textField) { + public SelectOutDirAction(JButton button, JTextField textField, SelectPathInterface selectPathInterface) { this.button = button; this.textField = textField; + this.selectPathInterface = selectPathInterface; if (SYS_NAME.contains("WIN")) { textField.setText("out\\rk3568"); } @@ -58,6 +60,7 @@ public class SelectOutDirAction implements ActionListener { int returnVal = fcDlg.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { String filepath = fcDlg.getSelectedFile().getPath(); + selectPathInterface.getFilePath(fcDlg.getSelectedFile()); String fieldShowPath; if (filepath.contains(File.separator)) { String path = filepath.substring(0, filepath.lastIndexOf(File.separator)); @@ -77,4 +80,8 @@ public class SelectOutDirAction implements ActionListener { } } } + + public interface SelectPathInterface { + void getFilePath(File pathFile); + } } diff --git a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.form b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.form index 0404e5e16440964dd860401ff719e289d818fe65..fcd75d854ba4ff041c70de44118930382a036617 100644 --- a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.form +++ b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.form @@ -1,18 +1,4 @@ -
@@ -303,7 +289,7 @@ - + diff --git a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.java b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.java index ca0b4690da9f0c3e5c43ec17b3ad8bbe17b7dea6..65a6426026faf5303ac2407c7267904d3ab00b19 100644 --- a/hdc/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.java +++ b/hdc/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.java @@ -54,7 +54,7 @@ import static com.sk.gn.utils.FileUtil.writeTmpFile; * @version: v1.0.0 * @since 2022-02-21 */ -public class GenDialogPane extends JDialog { +public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectPathInterface { private static final Logger LOG = Logger.getInstance(GenDialogPane.class); private static final String SYS_NAME = System.getProperties().getProperty("os.name").toUpperCase(); @@ -128,11 +128,12 @@ public class GenDialogPane extends JDialog { contentPane.registerKeyboardAction(actionEvent -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - selectOPOutButton.addActionListener(new SelectOutDirAction(selectOPOutButton, opOutPathTextField)); - selectOPOriginButton.addActionListener(new SelectOriginCodeAction(selectOPOriginButton, opOriginTextField)); + selectOPOutButton.addActionListener(new SelectOutDirAction(selectOPOutButton, opOutPathTextField, this)); + selectOPOriginButton.addActionListener(new SelectOriginCodeAction(selectOPOriginButton, opOriginTextField, + opOutPathTextField)); selectTransplantButton.addActionListener(new SelectBankAction(selectTransplantButton, transplantTextField)); - selectScriptButton.addActionListener(new InputScriptAction(selectScriptButton, inputScriptTextField, - comboBox, transplantTextField)); + selectScriptButton.addActionListener(new InputScriptAction(selectScriptButton, inputScriptTextField, comboBox + , transplantTextField)); inputScriptTextField.setText(filePath); } @@ -293,8 +294,8 @@ public class GenDialogPane extends JDialog { } } String command = file.toString(); - command += " -o " + outputCodeDir + " -p " + originCodeDir + " -f " + inputScriptDir + " -t " + scriptType - + " -s " + subsystemName + " -m " + componentName + " -d " + transplantDir; + command += " -o " + outputCodeDir + " -p " + originCodeDir + " -f " + inputScriptDir + " -t " + scriptType + + " -s " + subsystemName + " -m " + componentName + " -d " + transplantDir; if (!TextUtils.isEmpty(compileTextField.getText().trim())) { command += " -a " + "\"" + compileOptions + "\""; } @@ -307,21 +308,21 @@ public class GenDialogPane extends JDialog { private void createCopyResMakeFile() { String makeFilePath = "cmds/res/linux/bin/make"; if (SYS_NAME.contains("WIN")) { - makeFilePath = "cmds/res/win/bin/gnumake.exe"; + makeFilePath = "cmds/res/win/bin/make.exe"; } String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/bin/"; File file = new File(tmpDirFile); if (file.mkdirs()) { LOG.info("create dir success"); } - String tmp = SYS_NAME.contains("WIN") ? file.getPath() + "/gnumake.exe" : file.getPath() + "/make"; + String tmp = SYS_NAME.contains("WIN") ? file.getPath() + "/make.exe" : file.getPath() + "/make"; writeTmpFile(tmp, makeFilePath, project); if (SYS_NAME.contains("LINUX") || SYS_NAME.contains("MAC OS")) { try { executable(tmp); } catch (IOException | InterruptedException e) { GenNotification.notifyMessage(this.project, e.getMessage(), "Can not Find File:" + makeFilePath, - NotificationType.ERROR); + NotificationType.ERROR); LOG.error(e); } } @@ -344,7 +345,7 @@ public class GenDialogPane extends JDialog { executable(tmp); } catch (IOException | InterruptedException e) { GenNotification.notifyMessage(this.project, e.getMessage(), "Can not Find File:" + makeFilePath, - NotificationType.ERROR); + NotificationType.ERROR); LOG.error(e); } } @@ -367,7 +368,7 @@ public class GenDialogPane extends JDialog { executable(tmp); } catch (IOException | InterruptedException e) { GenNotification.notifyMessage(this.project, e.getMessage(), "Can not Find File:" + toolchainFileDir, - NotificationType.ERROR); + NotificationType.ERROR); LOG.error(e); } } @@ -378,20 +379,34 @@ public class GenDialogPane extends JDialog { GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR); return false; } - Process process = Runtime.getRuntime().exec(command); - genResultLog(process); - StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream()); - StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream()); - errConsumer.start(); - outputConsumer.start(); - if (generateSuccess) { - GenNotification.notifyMessage(project, "执行成功", "提示", NotificationType.INFORMATION); - } else { - GenNotification.notifyMessage(project, sErrorMessage, "提示", NotificationType.ERROR); - return false; + try { + final Process process = Runtime.getRuntime().exec(command); + new Thread(() -> { + BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); + try { + while (br.readLine() != null) ; + LOG.info(" callExtProcess " + br.readLine()); + } catch (IOException ioException) { + LOG.error(" callExtProcess br error" + ioException); + } + }).start(); + genResultLog(process); + StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream()); + StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream()); + errConsumer.start(); + outputConsumer.start(); + if (generateSuccess) { + GenNotification.notifyMessage(project, "执行成功", "提示", NotificationType.INFORMATION); + } else { + GenNotification.notifyMessage(project, sErrorMessage, "提示", NotificationType.ERROR); + return false; + } + errConsumer.join(); + outputConsumer.join(); + process.destroy(); + } catch (Exception e) { + e.printStackTrace(); } - errConsumer.join(); - outputConsumer.join(); return true; } @@ -477,6 +492,14 @@ public class GenDialogPane extends JDialog { return sOut.toString(); } + @Override + public void getFilePath(File pathFile) { + if (pathFile.getParentFile() != null && pathFile.getParentFile().getParent() != null) { + opOriginTextField.setText(pathFile.getParentFile().getParent()); + inputScriptTextField.setText(pathFile.getParentFile().getParent()); + } + } + static class StreamConsumer extends Thread { InputStream is; diff --git a/hdc/service_IntelliJ_plugin/src/com/sk/service/dialog/ServiceGenerateDialogPane.form b/hdc/service_IntelliJ_plugin/src/com/sk/service/dialog/ServiceGenerateDialogPane.form index 987dedf17d45e5e341cafcd2f92f4bffb40377be..a2b8b2e9870ce71856081bc0a2e9314d30701ee2 100644 --- a/hdc/service_IntelliJ_plugin/src/com/sk/service/dialog/ServiceGenerateDialogPane.form +++ b/hdc/service_IntelliJ_plugin/src/com/sk/service/dialog/ServiceGenerateDialogPane.form @@ -1,18 +1,4 @@ - @@ -30,11 +16,6 @@ - - - - - @@ -114,6 +95,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/hdc/service_IntelliJ_plugin/src/com/sk/service/dialog/ServiceGenerateDialogPane.java b/hdc/service_IntelliJ_plugin/src/com/sk/service/dialog/ServiceGenerateDialogPane.java index e4b7bd9811a9b0fcb741e13e54d6c37d000f5450..2d72a87abb1b642251b60c5884ddb48ef23305f7 100644 --- a/hdc/service_IntelliJ_plugin/src/com/sk/service/dialog/ServiceGenerateDialogPane.java +++ b/hdc/service_IntelliJ_plugin/src/com/sk/service/dialog/ServiceGenerateDialogPane.java @@ -60,6 +60,7 @@ public class ServiceGenerateDialogPane extends JDialog { private JTextField textFieldOutPath; private JButton buttonOutPath; private JButton buttonSelectH; + private JTextField textFieldServiceId; private boolean generateSuccess = true; private String sErrorMessage = ""; private String dirPath; @@ -199,7 +200,8 @@ public class ServiceGenerateDialogPane extends JDialog { String command = file.toString(); String hFile = textFieldH.getText(); String outPath = textFieldOutPath.getText(); - command += " -f " + hFile + " -o " + outPath + " -s 9001"; + String serviceId = textFieldServiceId.getText(); + command += " -f " + hFile + " -o " + outPath + (TextUtils.isEmpty(serviceId) ? " -s 9001" : " -s " + serviceId); return command; } diff --git a/napi_vs_plugin/src/package.json b/napi_vs_plugin/src/package.json index 2d37783a0c4103d15f94ddefd8730bddc3e86a33..5519e22001fd7549bd34e431d98244229317246c 100644 --- a/napi_vs_plugin/src/package.json +++ b/napi_vs_plugin/src/package.json @@ -29,6 +29,10 @@ { "when": "resourceExtname == .ts", "command": "generate_napi" + }, + { + "when": "resourceExtname == .h", + "command": "generate_napi" } ], "editor/context": [ diff --git a/napi_vs_plugin/src/vs_plugin_view.html b/napi_vs_plugin/src/vs_plugin_view.html index 2714fa7457dbb9beb12f13a877746b3a51255639..79b7f2a27b248d202f8646d93caea4f78c2d1c15 100644 --- a/napi_vs_plugin/src/vs_plugin_view.html +++ b/napi_vs_plugin/src/vs_plugin_view.html @@ -191,7 +191,7 @@ document.getElementById("hFilePath").value = path; fillInputDir(path, message); } else if(message == "selectHResultDir") { - document.getElementById("genHResultDir").value = dir; + document.getElementById("genHResultDir").value = path; } else { console.log("param is error");