Browse Source

Pull request #10296: REPORT-81880 优化模板定位逻辑

Merge in DESIGN/design from ~DESTINY.LIN/design:release/11.0 to release/11.0

* commit '8c49d129f865cd7880615733944cfb6d9c42bf79':
  REPORT-81880 优化模板定位逻辑
  REPORT-81880 优化模板定位逻辑
  REPORT-81880 优化模板定位逻辑
release/11.0
Destiny.Lin-林锦龙 2 years ago
parent
commit
1d2a9c466a
  1. 50
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  2. 7
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java

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();
}
/**
* 激活模板
* <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
*/
public boolean isServerConfig() {
@ -1239,6 +1288,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/**
* 设置是否正在进行服务器配置
*
* @param serverConfig
*/
public void setServerConfig(boolean serverConfig) {

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.i18n.Toolkit;
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.general.GeneralUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.AbstractCellEditor;
@ -44,14 +46,13 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor
if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) {
ITReplaceMainDialog.setITReplaceFlag(true);
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);
}
ITReplaceMainDialog.setITReplaceFlag(false);
}
});
}
/**

Loading…
Cancel
Save