Skip to content

Commit

Permalink
feat: Ecm脚本修改 (#671)
Browse files Browse the repository at this point in the history
* feat(smc): 修改ecm脚本处理

* feat: update licenseDialog

* feat(smc): Add groovy

---------
  • Loading branch information
unknowIfGuestInDream committed Aug 29, 2023
1 parent 38d81ab commit 4de2914
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ private FxButtonType() {
public static final ButtonType CANCEL = new ButtonType(I18nUtils.get("core.buttonType.cancel"),
ButtonData.CANCEL_CLOSE);

public static final ButtonType COPY = new ButtonType(I18nUtils.get("core.button.copy"), ButtonData.YES);

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
package com.tlcsdm.core.javafx.dialog;

import com.tlcsdm.core.javafx.FxApp;
import com.tlcsdm.core.javafx.util.OSUtil;
import com.tlcsdm.core.util.CoreConstant;
import javafx.scene.control.ButtonType;
import javafx.scene.layout.Priority;
Expand Down Expand Up @@ -56,8 +57,10 @@ public static void openLicenseDialog() {
vbox.getChildren().addAll(pane);
VBox.setVgrow(pane, Priority.ALWAYS);
FxDialog<VBox> dialog = new FxDialog<VBox>().setTitle("License").setOwner(FxApp.primaryStage)
.setPrefSize(680, 520).setResizable(true).setBody(vbox).setButtonTypes(ButtonType.CLOSE);
dialog.setButtonHandler(ButtonType.CLOSE, (e, s) -> s.close());
.setPrefSize(680, 520).setResizable(true).setBody(vbox).setButtonTypes(FxButtonType.COPY, ButtonType.CLOSE);
dialog.setButtonHandler(FxButtonType.COPY, (actionEvent, stage) -> {
OSUtil.writeToClipboard(area.getText());
}).setButtonHandler(ButtonType.CLOSE, (e, s) -> s.close());
dialog.show();
}

Expand Down
2 changes: 1 addition & 1 deletion qe/src/main/java/com/tlcsdm/qe/util/QeConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public class QeConstant {
* 当前项目加的依赖
*/
public static final List<String> DEPENDENCY_LIST = List.of("poi", "freemarker", "dom4j", "java-diff-utils",
"richtextfx", "thumbnailator");
"richtextfx", "thumbnailator", "groovy");

private QeConstant() {
}
Expand Down
1 change: 0 additions & 1 deletion qe/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
requires org.slf4j;
requires freemarker;
requires javafx.base;
requires org.apache.groovy;

exports com.tlcsdm.qe;
exports com.tlcsdm.qe.provider to com.tlcsdm.frame, com.tlcsdm.login;
Expand Down
4 changes: 4 additions & 0 deletions smc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,9 @@ public void initializeBindings() {
super.initializeBindings();
BooleanBinding outputValidation = new TextInputControlEmptyBinding(outputField).build();
BooleanBinding emptyValidation = new MultiTextInputControlEmptyBinding(excelField, outputField, sheetNameField,
startRowField, categorySheetNameField, categoryStartRowField, categoryConfigField,
errorSourceIdColField, categoryIdColField, errorSourceNumberColField, errorSourceEnNameColField,
errorSourceDescColField, errorSourceJpNameColField, functionConfigField, productConfigField,
tagConfigField).build();
startRowField, categorySheetNameField, categoryStartRowField, categoryConfigField, errorSourceIdColField,
categoryIdColField, errorSourceNumberColField, errorSourceEnNameColField, errorSourceDescColField,
errorSourceJpNameColField, functionConfigField, productConfigField, tagConfigField).build();
generate.disabledProperty().bind(emptyValidation);
openOutDir.disabledProperty().bind(outputValidation);
FileChooserUtil.setOnDrag(excelField, FileChooserUtil.FileType.FILE);
Expand Down Expand Up @@ -546,7 +545,7 @@ protected void dealProductData() {
* 获取tag数据
*/
protected List<Map<String, Object>> buildTagData(LinkedHashMap<String, String> tagMap, ExcelReader reader,
int rowNum) {
int rowNum) {
List<Map<String, Object>> tag = new ArrayList<>();
for (String tagkey : tagMap.keySet()) {
String tagCol = tagMap.get(tagkey);
Expand Down Expand Up @@ -619,7 +618,7 @@ public String getSampleDescription() {

@Override
public String getSampleVersion() {
return "1.0.3";
return "1.0.6";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected void handlerErrorSourceMap(Map<String, Object> errorSource, String pro
}

private void generateErrort(int size, String support, String errorNote, List<Map<String, Object>> extraFunc,
List<Map<String, Object>> function) {
List<Map<String, Object>> function) {
for (int i = 0; i < size; i++) {
Map<String, Object> map = new HashMap<>();
map.put("funcId", "optErrort" + i);
Expand All @@ -168,7 +168,7 @@ private void generateErrort(int size, String support, String errorNote, List<Map
}

protected void handlerOperationSupport(Map<String, Object> operation, String funcSupCondition,
boolean optMaskintStatus) {
boolean optMaskintStatus) {
if (funcSupCondition.contains("*")) {
String mesNum = StrUtil.subAfter(funcSupCondition, "*", true);
if ("1".equals(mesNum) || "2".equals(mesNum)) {
Expand Down Expand Up @@ -208,23 +208,10 @@ private String cleanErrorSourceData(String data) {
data = list.get(0);
for (int i = 1; i < list.size(); i++) {
data += " ";
data += list.get(i).replaceFirst("- ", "-");
data += list.get(i);
}
}
data = data.replaceAll("-", " - ");
data = data.replaceAll(" ", " ");
if (data.contains(" - bit")) {
data = data.replaceAll(" - bit", "-bit");
}
if (data.contains("P - Bus")) {
data = data.replaceAll("P - Bus", "P-Bus");
}
if (data.contains("I - Bus")) {
data = data.replaceAll("I - Bus", "I-Bus");
}
if (data.contains("H - Bus")) {
data = data.replaceAll("H - Bus", "H-Bus");
}
return data;
}
}
20 changes: 3 additions & 17 deletions smc/src/main/java/com/tlcsdm/smc/codeDev/ecm/C1MEcmScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ protected Map<String, Object> dealErrorSourceData(ExcelReader reader, int rowNum
String tagValue = reader.getCell(tagCol + rowNum).getStringCellValue();
Map<String, Object> tagMeta = new HashMap<>();
if ("psedu".equals(tagkey)) {
tagValue = String
.valueOf(Boolean.valueOf(!"―".equals(tagValue) && tagValue.trim().length() > 0));
tagValue = String.valueOf(Boolean.valueOf(!"―".equals(tagValue) && tagValue.trim().length() > 0));
}
tagMeta.put("key", tagkey);
tagMeta.put("value", tagValue);
Expand Down Expand Up @@ -223,27 +222,14 @@ private String cleanErrorSourceData(String data) {
data = list.get(0);
for (int i = 1; i < list.size(); i++) {
data += " ";
data += list.get(i).replaceFirst("- ", "-");
data += list.get(i);
}
}
data = data.replaceAll("-", " - ");
data = data.replaceAll(" ", " ");
if (data.contains(" - bit")) {
data = data.replaceAll(" - bit", "-bit");
}
if (data.contains("P - Bus")) {
data = data.replaceAll("P - Bus", "P-Bus");
}
if (data.contains("I - Bus")) {
data = data.replaceAll("I - Bus", "I-Bus");
}
if (data.contains("H - Bus")) {
data = data.replaceAll("H - Bus", "H-Bus");
}
if (data.contains("*")) {
List<String> list = StrUtil.split(data, "*");
data = list.get(0);
}
data = data.replaceAll(" ", " ");
return data;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,9 @@ private String cleanErrorSourceData(String data) {
data = list.get(0);
for (int i = 1; i < list.size(); i++) {
data += " ";
data += list.get(i).replaceFirst("- ", "-");
data += list.get(i);
}
}
data = data.replaceAll("-", " - ");
data = data.replaceAll(" ", " ");
return data;
}
Expand All @@ -165,11 +164,6 @@ public String getSampleId() {
return "u2CEcmScript";
}

@Override
public String getSampleVersion() {
return "1.0.5";
}

@Override
public String getSampleName() {
return "U2CEcmScript";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2019, 2023 unknowIfGuestInDream
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of unknowIfGuestInDream, any associated website, nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL UNKNOWIFGUESTINDREAM BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package com.tlcsdm.smc.config;

import com.tlcsdm.core.groovy.GroovyLoaderService;

import java.util.Objects;

public class SmcGroovyLoaderProvider implements GroovyLoaderService {

@Override
public String getGroovyLoaderPath() {
return Objects.requireNonNull(SmcGroovyLoaderProvider.class.getResource("/com/tlcsdm/smc/static/groovy")).getPath();
}

}
2 changes: 1 addition & 1 deletion smc/src/main/java/com/tlcsdm/smc/util/SmcConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public class SmcConstant {
* 当前项目加的依赖
*/
public static final List<String> DEPENDENCY_LIST = List.of("poi", "freemarker", "dom4j", "java-diff-utils",
"richtextfx", "thumbnailator");
"richtextfx", "thumbnailator", "groovy");

private SmcConstant() {
}
Expand Down
3 changes: 3 additions & 0 deletions smc/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

import com.tlcsdm.core.freemarker.TemplateLoaderService;
import com.tlcsdm.core.groovy.GroovyLoaderService;
import com.tlcsdm.frame.service.CenterPanelService;
import com.tlcsdm.frame.service.FXSamplerConfiguration;
import com.tlcsdm.frame.service.FXSamplerProject;
Expand All @@ -35,6 +36,7 @@
import com.tlcsdm.frame.service.SplashScreen;
import com.tlcsdm.frame.service.VersionCheckerService;
import com.tlcsdm.login.service.LoginCheck;
import com.tlcsdm.smc.config.SmcGroovyLoaderProvider;
import com.tlcsdm.smc.config.SmcTemplateLoaderProvider;
import com.tlcsdm.smc.provider.SmcCenterPanelProvider;
import com.tlcsdm.smc.provider.SmcConfigurationProvider;
Expand Down Expand Up @@ -87,6 +89,7 @@
provides SplashScreen with SmcSplashProvider;
provides LoginCheck with SmcLoginCheckProvider;
provides TemplateLoaderService with SmcTemplateLoaderProvider;
provides GroovyLoaderService with SmcGroovyLoaderProvider;
provides SamplePostProcessorService with SmcSamplePostProcessorProvider;
provides VersionCheckerService with SmcVersionCheckerProvider;
provides SamplesTreeViewConfiguration with SmcSampleTreeViewConfiguration;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.tlcsdm.smc.config.SmcGroovyLoaderProvider
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def hello() {
println "Hello QE"
demo()
return "success, hello QE"
}

def demo() {
println "Hello demo"
}

hello()
println "Hello, welcome to Groovy!"

0 comments on commit 4de2914

Please sign in to comment.