Browse Source

REPORT-81880 优化模板定位逻辑

newui
Destiny.Lin 2 years ago
parent
commit
52a7153ff0
  1. 40
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java

40
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,11 +46,43 @@ 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())); FILE tplFile = FILEFactory.createFILE(content.getTemplatePath());
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl); if (tplFile != null && tplFile.exists()) {
//模板已保存
navigate2ExistedTemplate(tplFile, trl);
} else {
//模板未保存
navigate2NotExistedTemplate(content, trl);
}
} }
ITReplaceMainDialog.setITReplaceFlag(false); ITReplaceMainDialog.setITReplaceFlag(false);
} }
/**
* 模板未保存的跳转逻辑
* @param content 存储模板名称的数据结构
* @param trl 跳转链接
*/
private void navigate2NotExistedTemplate(ITContent content, TRL trl) {
java.util.List<JTemplate<?, ?>> openTemplates = HistoryTemplateListCache.getInstance().getHistoryList();
for (int i = 0, len = openTemplates.size(); i < len; i++) {
if (StringUtils.equals(openTemplates.get(i).getTemplateName(), content.getTemplateName())) {
DesignerContext.getDesignerFrame().activateJTemplate(openTemplates.get(i));
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl);
break;
}
}
}
/**
* 模板已保存的跳转逻辑
* @param tplFile 模板的FILE文件
* @param trl 跳转链接
*/
private void navigate2ExistedTemplate(FILE tplFile, TRL trl) {
DesignerContext.getDesignerFrame().openTemplate(tplFile);
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl);
}
}); });

Loading…
Cancel
Save