Browse Source

Merge pull request #10320 in DESIGN/design from release/11.0 to bugfix/11.0

* commit '677526ad71f1f662e21ac03cb88344a5d89ba1cc':
  REPORT-81973 搜索模板时没预加载完就开始搜索,没构建出模板树
  REPORT-75998 更换菜单位置到“模板”
  REPORT-76857 云端运维插件也会被环境检测检测到 删掉一个单元测试。依赖于环境,不稳定
  REPORT-76857 云端运维插件也会被环境检测检测到 只检测 web-inf/lib 和 designer/lib 下面的。 忽视插件
  REPORT-81880 优化模板定位逻辑
  REPORT-81880 优化模板定位逻辑
  REPORT-81880 优化模板定位逻辑
bugfix/11.0
superman 2 years ago
parent
commit
ce0818a0c8
  1. 3
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  2. 50
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  3. 5
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  4. 8
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  5. 18
      designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java
  6. 4
      designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java
  7. BIN
      designer-base/src/main/resources/com/fr/design/images/replace/replace.png
  8. 3
      designer-base/src/main/resources/com/fr/design/images/replace/replace_normal.svg
  9. 12
      designer-base/src/test/java/com/fr/env/detect/impl/converter/ClassConflictConvertorTest.java
  10. 1
      designer-realize/src/main/java/com/fr/design/actions/replace/ITReplaceAction.java
  11. 7
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java

3
designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java

@ -306,8 +306,7 @@ public class TemplateFileTree extends EnvFileTree {
if (interceptRefresh(root)) { if (interceptRefresh(root)) {
return; return;
} }
if (!TemplateTreeSearchManager.getInstance().isRefreshing() || TemplateTreeSearchManager.getInstance().allFileNodes().size() != allTreeNode.size()) {
if (!TemplateTreeSearchManager.getInstance().isRefreshing()) {
currentTreeMode.clear(); currentTreeMode.clear();
calculateNode.clear(); calculateNode.clear();
allTreeNode = TemplateTreeSearchManager.getInstance().allFileNodes().entrySet().stream().collect( allTreeNode = TemplateTreeSearchManager.getInstance().allFileNodes().entrySet().stream().collect(

50
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -886,6 +886,54 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
layeredPane.repaint(); layeredPane.repaint();
} }
/**
* 激活模板
* <p>
* activateJTemplate需要模板存在openTemplate需要模板保存过该方法模板保存与未保存皆可激活模板如果关闭并且保存过会重新打开
*
* @param templatePath 模板路径 template.getPath()
*/
public void openOrActiveTemplate(String templatePath) {
//没保存过的模板如果要激活就要从当前历史模板列表里面找
String templateName = getTemplateNameFromPath(templatePath);
if (isTemplateNeverSaved(templatePath)) {
int index = HistoryTemplateListCache.getInstance().contains(templateName);
//如果历史模板列表中存在则激活
if (index != -1) {
DesignerContext.getDesignerFrame().activateJTemplate(HistoryTemplateListCache.getInstance().getTemplate(index));
}
} else {
DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(templatePath));
}
}
/**
* 指定路径的模板是否保存过
*
* @param templatePath 模板路径 template.getPath()
* @return 如果模板没保存过则返回true
*/
private boolean isTemplateNeverSaved(String templatePath) {
FILE tplFile = FILEFactory.createFILE(templatePath);
//没保存过的模板获取到的templatePath所生成的FILE文件会不存在
return tplFile == null || !tplFile.exists() || StringUtils.isEmpty(templatePath);
}
/**
* 根据模板路径获取模板名称
* @param templatePath 模板路径 template.getPath()
* @return 模板名
*/
private String getTemplateNameFromPath(String templatePath) {
FILE tplFile = FILEFactory.createFILE(templatePath);
String templateName = StringUtils.EMPTY;
if (tplFile != null) {
templateName = tplFile.getName();
}
return templateName;
}
/** /**
* 当前模板 停用失败 * 当前模板 停用失败
* *
@ -1231,6 +1279,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/** /**
* 判断是否正在进行服务器配置 * 判断是否正在进行服务器配置
*
* @return boolean * @return boolean
*/ */
public boolean isServerConfig() { public boolean isServerConfig() {
@ -1239,6 +1288,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/** /**
* 设置是否正在进行服务器配置 * 设置是否正在进行服务器配置
*
* @param serverConfig * @param serverConfig
*/ */
public void setServerConfig(boolean serverConfig) { public void setServerConfig(boolean serverConfig) {

5
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -54,6 +54,7 @@ import com.fr.design.mainframe.toolbar.VcsScene;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.NameSeparator; import com.fr.design.menu.NameSeparator;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.preview.PagePreview; import com.fr.design.preview.PagePreview;
import com.fr.design.ui.util.UIUtil; import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
@ -1109,6 +1110,10 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
tplMenu.addShortCut(shortCuts4Authority()); tplMenu.addShortCut(shortCuts4Authority());
} }
//查找替换
tplMenu.addShortCut(new NameSeparator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Replace_Name_Separate")));
tplMenu.addShortCut((ShortCut) DesignModuleFactory.getITReplaceAction());
return new MenuDef[]{tplMenu}; return new MenuDef[]{tplMenu};
} }

8
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -580,13 +580,7 @@ public abstract class ToolBarMenuDock {
} }
shortCuts.add(new AboutAction()); shortCuts.add(new AboutAction());
try {
if (DesignModuleFactory.getITReplaceAction() != null) {
shortCuts.add((ShortCut) DesignModuleFactory.getITReplaceAction().newInstance());
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return shortCuts.toArray(new ShortCut[0]); return shortCuts.toArray(new ShortCut[0]);
} }

18
designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java

@ -19,6 +19,7 @@ import com.fr.log.FineLoggerFactory;
import com.fr.plugin.solution.sandbox.collection.PluginSandboxCollections; import com.fr.plugin.solution.sandbox.collection.PluginSandboxCollections;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.awt.Dialog; import java.awt.Dialog;
@ -129,8 +130,21 @@ public class DesignModuleFactory {
instance.ITReplaceAction = r; instance.ITReplaceAction = r;
} }
public static Class getITReplaceAction() { /**
return instance.ITReplaceAction; * 获取查找替换
*
* @return ITReplaceAction
*/
@Nullable
public static Object getITReplaceAction() {
try {
if (instance.ITReplaceAction != null) {
return instance.ITReplaceAction.newInstance();
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
} }
/** /**

4
designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java vendored

@ -48,6 +48,7 @@ public class ClassConflictConvertor implements ThrowableConverter {
private static final String JAR_URL_SUFFIX = ".jar!"; private static final String JAR_URL_SUFFIX = ".jar!";
private static final String JAR_FILE_SUFFIX = ".jar"; private static final String JAR_FILE_SUFFIX = ".jar";
private static final String FILE_URL_PREFIX = "file:"; private static final String FILE_URL_PREFIX = "file:";
private static final String PLUGINS_DIR_NAME = "plugins";
private final Map<Class<?>, ClassNameConverter> throwableMap = new HashMap<>(); private final Map<Class<?>, ClassNameConverter> throwableMap = new HashMap<>();
@ -108,6 +109,9 @@ public class ClassConflictConvertor implements ThrowableConverter {
for (URL url : urlList) { for (URL url : urlList) {
String file = url.getFile(); String file = url.getFile();
String decodeFileStr = URLDecoder.decode(file, EncodeConstants.ENCODING_UTF_8); String decodeFileStr = URLDecoder.decode(file, EncodeConstants.ENCODING_UTF_8);
if (decodeFileStr.contains(PLUGINS_DIR_NAME)) {
continue;
}
if (decodeFileStr.contains(JAR_URL_SUFFIX)) { if (decodeFileStr.contains(JAR_URL_SUFFIX)) {
String jarPath = decodeFileStr.substring(FILE_URL_PREFIX.length(), decodeFileStr.indexOf(JAR_URL_SUFFIX) + JAR_FILE_SUFFIX.length()); String jarPath = decodeFileStr.substring(FILE_URL_PREFIX.length(), decodeFileStr.indexOf(JAR_URL_SUFFIX) + JAR_FILE_SUFFIX.length());
String jar = new File(jarPath).getName(); String jar = new File(jarPath).getName();

BIN
designer-base/src/main/resources/com/fr/design/images/replace/replace.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

3
designer-base/src/main/resources/com/fr/design/images/replace/replace_normal.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.90857 12.5269C3.871 12.5269 1.40857 10.0644 1.40857 7.02686C1.40857 3.98929 3.871 1.52686 6.90857 1.52686C9.94614 1.52686 12.4086 3.98929 12.4086 7.02686C12.4086 8.28787 11.9842 9.44977 11.2705 10.3775L14.3701 13.5236C14.6528 13.8062 14.6528 14.2645 14.3701 14.5472C14.0874 14.8298 13.6292 14.8298 13.3465 14.5472L10.2452 11.3995C9.31981 12.1067 8.16326 12.5269 6.90857 12.5269ZM11.4086 7.02686C11.4086 9.51214 9.39385 11.5269 6.90857 11.5269C4.42329 11.5269 2.40857 9.51214 2.40857 7.02686C2.40857 4.54157 4.42329 2.52686 6.90857 2.52686C9.39385 2.52686 11.4086 4.54157 11.4086 7.02686Z" fill="#333334"/>
</svg>

After

Width:  |  Height:  |  Size: 761 B

12
designer-base/src/test/java/com/fr/env/detect/impl/converter/ClassConflictConvertorTest.java vendored

@ -1,5 +1,6 @@
package com.fr.env.detect.impl.converter; package com.fr.env.detect.impl.converter;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
public class ClassConflictConvertorTest { public class ClassConflictConvertorTest {
@ -10,14 +11,7 @@ public class ClassConflictConvertorTest {
ClassNotFoundException ex1 = new ClassNotFoundException("Class 111.222.333 not found"); ClassNotFoundException ex1 = new ClassNotFoundException("Class 111.222.333 not found");
Iterable<String> names = ClassConflictConvertor.Converter.CLASS.converter(ex1); Iterable<String> names = ClassConflictConvertor.Converter.CLASS.converter(ex1);
System.out.println(); String next = names.iterator().next();
} Assert.assertEquals("111.222.333", next);
@Test
public void testConverter() {
ClassNotFoundException ex1 = new ClassNotFoundException("com.zaxxer.hikari.HikariConfig");
ClassConflictConvertor convertor = new ClassConflictConvertor();
convertor.convert(ex1);
} }
} }

1
designer-realize/src/main/java/com/fr/design/actions/replace/ITReplaceAction.java

@ -29,6 +29,7 @@ public class ITReplaceAction extends UpdateAction {
this.setName(getMenuKeySet().getMenuName()); this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setAccelerator(getMenuKeySet().getKeyStroke()); this.setAccelerator(getMenuKeySet().getKeyStroke());
this.setSmallIcon("/com/fr/design/images/replace/replace");
} }
private static final MenuKeySet IT_REPLACE = new MenuKeySet() { private static final MenuKeySet IT_REPLACE = new MenuKeySet() {

7
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java

@ -6,10 +6,12 @@ import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE;
import com.fr.file.FILEFactory; import com.fr.file.FILEFactory;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.AbstractCellEditor; import javax.swing.AbstractCellEditor;
@ -44,14 +46,13 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor
if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) { if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) {
ITReplaceMainDialog.setITReplaceFlag(true); ITReplaceMainDialog.setITReplaceFlag(true);
TRL trl = new TRL(GeneralUtils.objectToString(content.getTrlString())); TRL trl = new TRL(GeneralUtils.objectToString(content.getTrlString()));
DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(content.getTemplatePath())); DesignerContext.getDesignerFrame().openOrActiveTemplate(content.getTemplatePath());
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl);
} }
ITReplaceMainDialog.setITReplaceFlag(false); ITReplaceMainDialog.setITReplaceFlag(false);
} }
}); });
} }
/** /**

Loading…
Cancel
Save