From ba04ea99b0f72515fc6965a48e3090e4b1d96784 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 11 Oct 2022 15:49:46 +0800 Subject: [PATCH 1/7] =?UTF-8?q?REPORT-75998=20=E4=BF=AE=E5=A4=8D=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E7=B1=BB=E5=9E=8B=E5=9B=BE=E8=A1=A8=E7=9A=84=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=B8=ADJS=E7=BC=BA=E6=BC=8F=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/utils/SearchJSUtils.java | 90 ++++++++++++++++--- .../actions/replace/utils/ShowValueUtils.java | 22 +++++ 2 files changed, 100 insertions(+), 12 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java index d04b02aa2..5bb27c668 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java @@ -21,6 +21,9 @@ import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.AttrLabel; import com.fr.plugin.chart.base.AttrTooltip; import com.fr.plugin.chart.base.VanChartHtmlLabel; +import com.fr.plugin.chart.map.VanChartMapPlot; +import com.fr.plugin.chart.map.attr.AttrMapLabel; +import com.fr.plugin.chart.map.attr.AttrMapTooltip; import com.fr.plugin.chart.vanchart.VanChart; import com.fr.report.cell.Elem; import com.fr.stable.StringUtils; @@ -39,6 +42,21 @@ import java.util.List; */ public class SearchJSUtils { + /** + * 样式-数据点提示 + */ + public static final String STYLE_TOOLTIP_CUSTOM = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Style"), Toolkit.i18nText("Fine-Design_Chart_Tooltip")); + + /** + * 样式-标签 + */ + public static final String STYLE_LABEL = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Style"), Toolkit.i18nText("Fine-Design_Chart_Data_Label")); + + /** + * 样式-分类标签 + */ + public static final String CATEGORY_LABEL = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Style"), Toolkit.i18nText("Fine-Design_Chart_Data_Label"), Toolkit.i18nText("Fine-Design_Chart_Category_Label")); + /** * 从Listener中获取JS */ @@ -118,29 +136,77 @@ public class SearchJSUtils { */ private static void addAttrLabelHtmlLabel(VanChart chart, List> arrayList) { VanChartPlot plot = chart.getPlot(); - addAttrToolTipCondition2Array(plot, arrayList); - if (isAttrLabelExist(plot)) { - addAttrLabelDetail2Array(plot, arrayList); - addAttrSecondLabelDetail2Array(plot, arrayList); + //如果是地图类型要特殊处理 + if (plot instanceof VanChartMapPlot) { + addMapJS2Array((VanChartMapPlot) plot, arrayList); + } else { + addAttrToolTipCondition2Array(plot, arrayList); + if (isAttrLabelExist(plot)) { + addAttrLabelDetail2Array(plot, arrayList); + addAttrSecondLabelDetail2Array(plot, arrayList); + } + } + } + /** + * 用于处理地图类型图表中的样式中的JS(AttrMapTooltip 与 AttrMapLabel) + * + * @param plot + * @param arrayList + */ + private static void addMapJS2Array(VanChartMapPlot plot, List> arrayList) { + ConditionAttr defaultAttr = plot.getConditionCollection().getDefaultAttr(); + AttrMapTooltip attrMapTooltip = defaultAttr.getExisted(AttrMapTooltip.class); + AttrMapLabel attrMapLabel = defaultAttr.getExisted(AttrMapLabel.class); + //处理三种地图的数据点提示——点地图、流向地图、区域地图 + dealMapTooltipJS(attrMapTooltip.getAreaTooltip(), arrayList); + dealMapTooltipJS(attrMapTooltip.getLineTooltip(), arrayList); + dealMapTooltipJS(attrMapTooltip.getPointTooltip(), arrayList); + + //处理两种地图的标签——点地图、区域地图(流向地图没有标签) + dealMapLabelJS(attrMapLabel.getAreaLabel(), arrayList); + dealMapLabelJS(attrMapLabel.getPointLabel(), arrayList); + + + } + + /** + * 用于处理地图类型图表中的标签中的JS + * + * @param label 地图类型的标签(点地图、区域地图) + * @param arrayList 用于存储htmlLabel的数组 + */ + private static void dealMapLabelJS(AttrLabel label, List> arrayList) { + if (isAttrLabelValid(label)) { + arrayList.add(new Pair<>(label.getContent().getHtmlLabel(), STYLE_LABEL)); } + } + /** + * 用于处理地图类型图表中的数据点提示中的JS + * + * @param tooltip 地图类型的数据点提示(点地图、流向地图、区域地图) + * @param arrayList 用于存储htmlLabel的数组 + */ + private static void dealMapTooltipJS(AttrTooltip tooltip, List> arrayList) { + if (isToolTipValid(tooltip)) { + arrayList.add(new Pair<>(tooltip.getContent().getHtmlLabel(), STYLE_TOOLTIP_CUSTOM)); + } } private static void addAttrToolTipCondition2Array(VanChartPlot plot, List> arrayList) { - if (isToolTipValid(plot)) { - arrayList.add(new Pair<>(((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).getContent().getHtmlLabel(), - Toolkit.i18nText("Fine-Design_Chart_Tooltip") + "-" + Toolkit.i18nText("Fine-Design_Basic_Custom"))); + if (isToolTipValid(plot.getAttrTooltipFromConditionCollection())) { + arrayList.add(new Pair<>(((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).getContent().getHtmlLabel(), STYLE_TOOLTIP_CUSTOM)); } } - private static boolean isToolTipValid(VanChartPlot plot) { - return plot.getAttrTooltipFromConditionCollection() != null && ((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).isEnable() && plot.getAttrTooltipFromConditionCollection() instanceof AttrTooltip; + private static boolean isToolTipValid(DataSeriesCondition tooltip) { + return tooltip instanceof AttrTooltip && ((AttrTooltip) tooltip).isEnable() && ((AttrTooltip) tooltip).getContent() != null && ((AttrTooltip) tooltip).getContent().getHtmlLabel() != null; } private static void addAttrLabelDetail2Array(VanChartPlot plot, List> arrayList) { if (isLabelDetailValid(plot)) { - arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel(), Toolkit.i18nText("Fine-Design_Chart_Value_Label"))); + arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel(), STYLE_LABEL)); } } @@ -152,7 +218,7 @@ public class SearchJSUtils { private static void addAttrSecondLabelDetail2Array(VanChartPlot plot, List> arrayList) { if (isSecondLabelDetailValid(plot)) { - arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getSecondLabelDetail().getContent().getHtmlLabel(), Toolkit.i18nText("Fine-Design_Chart_Category_Label"))); + arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getSecondLabelDetail().getContent().getHtmlLabel(), CATEGORY_LABEL)); } } @@ -194,7 +260,7 @@ public class SearchJSUtils { } private static boolean isAttrLabelValid(AttrLabel label) { - return label.isEnable() && label.getContent() != null && label.getContent().getHtmlLabel() != null; + return label != null && label.isEnable() && label.getContent() != null && label.getContent().getHtmlLabel() != null; } /** diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java index b7b46539b..d01b475a9 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java @@ -46,6 +46,8 @@ public class ShowValueUtils { public static final int HTML_TAIL_LEN = HTML_TAIL.length(); public static final int NOBR_LEN = NOBR.length(); public static final int NOBR_TAIL_LEN = NOBR_TAIL.length(); + + public static final String JOIN_GAP_STRING = "-"; /** * <转变为<的长度差 */ @@ -301,4 +303,24 @@ public class ShowValueUtils { } } + + + /** + * 用于拼接展示位置用的字符串,中间用“-”拼接 + * + * @param strings 用于拼接的字符串 + * @return 拼接后的字符串 + */ + public static String joinStr4Position(String... strings) { + StringBuilder builder = new StringBuilder(); + int len = strings.length; + for (int i = 0; i < len; i++) { + if (i == 0) { + builder.append(strings[i]); + } else { + builder.append(JOIN_GAP_STRING).append(strings[i]); + } + } + return builder.toString(); + } } From 501506f39e9394eb1ca5fc42380dce573226c84b Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 11 Oct 2022 16:13:07 +0800 Subject: [PATCH 2/7] =?UTF-8?q?REPORT-75998=20=E6=8B=BC=E6=8E=A5=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E9=87=87=E7=94=A8StableUtils.join?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/replace/utils/ShowValueUtils.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java index d01b475a9..191a08eef 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java @@ -2,6 +2,7 @@ package com.fr.design.actions.replace.utils; import com.fr.design.actions.replace.ui.ITReplaceMainDialog; +import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; @@ -312,15 +313,6 @@ public class ShowValueUtils { * @return 拼接后的字符串 */ public static String joinStr4Position(String... strings) { - StringBuilder builder = new StringBuilder(); - int len = strings.length; - for (int i = 0; i < len; i++) { - if (i == 0) { - builder.append(strings[i]); - } else { - builder.append(JOIN_GAP_STRING).append(strings[i]); - } - } - return builder.toString(); + return StableUtils.join(strings, JOIN_GAP_STRING); } } From d65ce99715b72a6e958df756efe31393668a3c60 Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Tue, 11 Oct 2022 22:15:44 +0800 Subject: [PATCH 3/7] =?UTF-8?q?REPORT-81583=E3=80=90=E8=BF=90=E8=90=A5?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E5=8C=96=E4=BA=8C=E6=9C=9F=E3=80=91=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=8E=92=E5=BA=8F=E4=BD=BF=E7=94=A8=E5=90=91?= =?UTF-8?q?=E4=B8=8A=E6=88=96=E5=90=91=E4=B8=8B=E5=88=B0=E6=9C=80=E9=A1=B6?= =?UTF-8?q?=E6=88=96=E6=9C=80=E5=BA=95=E4=BA=A4=E4=BA=92=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=9C=89=E9=97=AE=E9=A2=98=EF=BC=9BREPORT-80117=20alphafine?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=85=8D=E7=BD=AE=E6=B2=A1=E6=9C=89=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=95=86=E5=9F=8E=EF=BC=8C=E9=A6=96=E6=AC=A1=E6=89=93?= =?UTF-8?q?=E5=BC=80=E5=8D=B4=E6=9C=89=E6=A8=A1=E6=9D=BF=E5=95=86=E5=9F=8E?= =?UTF-8?q?=201=E3=80=81=E4=BF=AE=E6=94=B9=E4=BA=A4=E4=BA=92=202=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=87=E7=BA=A7=E5=85=BC=E5=AE=B9=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/AlphaFineConfigManager.java | 3 ++ .../alphafine/component/CustomSortPane.java | 28 ++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java index 2e78d1062..7d02c0386 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java @@ -108,6 +108,7 @@ public class AlphaFineConfigManager implements XMLable { private Map actionSearchTextCache = new HashMap<>(8); private String cacheBuildNO; + private static final String CONTAIN_TEMPLATE_SHOP = "isContainTemplateShop"; /** * key: 登录的bbs用户 @@ -151,6 +152,7 @@ public class AlphaFineConfigManager implements XMLable { this.setContainPlugin(reader.getAttrAsBoolean("isContainDocument", true)); this.setContainDocument(reader.getAttrAsBoolean("isContainDocument", true)); this.setContainRecommend(reader.getAttrAsBoolean("isContainRecommend", true)); + this.setShowTemplateShop(reader.getAttrAsBoolean(CONTAIN_TEMPLATE_SHOP, true)); this.setContainAction(reader.getAttrAsBoolean("isContainAction", true)); this.setContainTemplate(reader.getAttrAsBoolean("isContainTemplate", true)); this.setContainFileContent(reader.getAttrAsBoolean("isContainFileContent", false)); @@ -258,6 +260,7 @@ public class AlphaFineConfigManager implements XMLable { .attr("needSegmentationCheckbox", this.isNeedSegmentationCheckbox()) .attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService()) .attr("productDynamics", this.isProductDynamics()) + .attr(CONTAIN_TEMPLATE_SHOP, this.showTemplateShop) .attr("tabOrder", this.getTabOrderString()); writeActionSearchTextCacheXML(writer); writeSearchHistory(writer); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java index c544bbac0..9e2af0937 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java @@ -85,7 +85,7 @@ public class CustomSortPane extends JPanel { top.addActionListener(e -> { SwingUtilities.invokeLater(() -> { sortItemPane.setComponentZOrder(selectedLabel, 0); - setToolbarEnable(false, false, true, true); + setToolbarEnable(sortItemPane.getComponentZOrder(selectedLabel), sortItemPane.getComponentCount()); CustomSortPane.this.revalidate(); CustomSortPane.this.repaint(); refreshCurrentOrder(); @@ -95,7 +95,7 @@ public class CustomSortPane extends JPanel { bottom.addActionListener(e -> { SwingUtilities.invokeLater(() -> { sortItemPane.setComponentZOrder(selectedLabel, sortItemPane.getComponentCount() - 1); - setToolbarEnable(true, true, false, false); + setToolbarEnable(sortItemPane.getComponentZOrder(selectedLabel), sortItemPane.getComponentCount()); CustomSortPane.this.revalidate(); CustomSortPane.this.repaint(); refreshCurrentOrder(); @@ -105,7 +105,7 @@ public class CustomSortPane extends JPanel { up.addActionListener(e -> { SwingUtilities.invokeLater(() -> { sortItemPane.setComponentZOrder(selectedLabel, sortItemPane.getComponentZOrder(selectedLabel) - 1); - setToolbarEnable(true, true, true, true); + setToolbarEnable(sortItemPane.getComponentZOrder(selectedLabel), sortItemPane.getComponentCount()); CustomSortPane.this.revalidate(); CustomSortPane.this.repaint(); refreshCurrentOrder(); @@ -115,7 +115,7 @@ public class CustomSortPane extends JPanel { down.addActionListener(e -> { SwingUtilities.invokeLater(() -> { sortItemPane.setComponentZOrder(selectedLabel, sortItemPane.getComponentZOrder(selectedLabel) + 1); - setToolbarEnable(true, true, true, true); + setToolbarEnable(sortItemPane.getComponentZOrder(selectedLabel), sortItemPane.getComponentCount()); CustomSortPane.this.revalidate(); CustomSortPane.this.repaint(); refreshCurrentOrder(); @@ -175,6 +175,26 @@ public class CustomSortPane extends JPanel { this.bottom.setEnabled(bottom); } + /** + * 根据选项当前位置以及菜单大小设置 置顶,上移,下移,置底 按钮的状态 + */ + private void setToolbarEnable(int order, int maxOrder) { + this.top.setEnabled(true); + this.up.setEnabled(true); + this.down.setEnabled(true); + this.bottom.setEnabled(true); + // 选项处于顶端,则置灰上移和置顶按钮 + if (order == 0) { + this.top.setEnabled(false); + this.up.setEnabled(false); + } + // 选项处于底端,则置灰下移和置底按钮 + if (order == maxOrder - 1) { + this.down.setEnabled(false); + this.bottom.setEnabled(false); + } + } + private void refreshCurrentOrder() { String[] currentTabOrder = parentPane.getCurrentOrder(); HashSet selectedTab = new HashSet<>(); From 16b56bb8ee42a2851d9344ff1e8be755f6b6345d Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 12 Oct 2022 21:16:51 +0800 Subject: [PATCH 4/7] =?UTF-8?q?REPORT-81416=20=E5=AF=BC=E5=85=A5=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/carton/EventDispatchThreadHangMonitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/carton/EventDispatchThreadHangMonitor.java b/designer-base/src/main/java/com/fr/design/carton/EventDispatchThreadHangMonitor.java index f472d901a..56ccaa2c4 100644 --- a/designer-base/src/main/java/com/fr/design/carton/EventDispatchThreadHangMonitor.java +++ b/designer-base/src/main/java/com/fr/design/carton/EventDispatchThreadHangMonitor.java @@ -7,7 +7,6 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.ProductConstantsBase; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import com.fr.third.ibm.icu.text.SimpleDateFormat; import org.jetbrains.annotations.NotNull; import javax.swing.SwingUtilities; @@ -22,6 +21,7 @@ import java.io.IOException; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; +import java.text.SimpleDateFormat; import java.util.LinkedList; import java.util.Timer; import java.util.TimerTask; From 52a7153ff0d45420cad706ba4d90b1a47a3cb945 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 13 Oct 2022 11:22:34 +0800 Subject: [PATCH 5/7] =?UTF-8?q?REPORT-81880=20=E4=BC=98=E5=8C=96=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=AE=9A=E4=BD=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/replace/ui/ITTableButton.java | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java index 1a73d3fcb..40e05e615 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java +++ b/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,11 +46,43 @@ 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())); - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl); + FILE tplFile = FILEFactory.createFILE(content.getTemplatePath()); + if (tplFile != null && tplFile.exists()) { + //模板已保存 + navigate2ExistedTemplate(tplFile, trl); + } else { + //模板未保存 + navigate2NotExistedTemplate(content, trl); + } } ITReplaceMainDialog.setITReplaceFlag(false); } + + /** + * 模板未保存的跳转逻辑 + * @param content 存储模板名称的数据结构 + * @param trl 跳转链接 + */ + private void navigate2NotExistedTemplate(ITContent content, TRL trl) { + java.util.List> 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); + } }); From 5b503ffba630dc6c9189702a0cb601762c3a3113 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 13 Oct 2022 16:07:40 +0800 Subject: [PATCH 6/7] =?UTF-8?q?REPORT-81880=20=E4=BC=98=E5=8C=96=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=AE=9A=E4=BD=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/DesignerFrame.java | 35 ++++++++++++++++++ .../actions/replace/ui/ITTableButton.java | 37 +------------------ 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index dfd2a20cd..a18cd724d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -886,6 +886,39 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta layeredPane.repaint(); } + /** + * 激活模板 + *

+ * activateJTemplate需要模板存在,openTemplate需要模板保存过,该方法模板保存与未保存皆可激活,模板如果关闭,并且保存过,会重新打开 + * + * @param templatePath 模板路径 template.getPath() + * @param templateName 模板名称 + */ + public void openOrActiveTemplate(String templatePath, String templateName) { + //没保存过的模板如果要激活就要从当前历史模板列表里面找 + 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); + } + /** * 当前模板 停用失败 * @@ -1231,6 +1264,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta /** * 判断是否正在进行服务器配置 + * * @return boolean */ public boolean isServerConfig() { @@ -1239,6 +1273,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta /** * 设置是否正在进行服务器配置 + * * @param serverConfig */ public void setServerConfig(boolean serverConfig) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java index 40e05e615..35ebedc72 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java @@ -46,46 +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())); - FILE tplFile = FILEFactory.createFILE(content.getTemplatePath()); - if (tplFile != null && tplFile.exists()) { - //模板已保存 - navigate2ExistedTemplate(tplFile, trl); - } else { - //模板未保存 - navigate2NotExistedTemplate(content, trl); - } + DesignerContext.getDesignerFrame().openOrActiveTemplate(content.getTemplatePath(), content.getTemplateName()); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl); } ITReplaceMainDialog.setITReplaceFlag(false); } - - /** - * 模板未保存的跳转逻辑 - * @param content 存储模板名称的数据结构 - * @param trl 跳转链接 - */ - private void navigate2NotExistedTemplate(ITContent content, TRL trl) { - java.util.List> 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); - } }); - } /** From 8c49d129f865cd7880615733944cfb6d9c42bf79 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 13 Oct 2022 18:47:14 +0800 Subject: [PATCH 7/7] =?UTF-8?q?REPORT-81880=20=E4=BC=98=E5=8C=96=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=AE=9A=E4=BD=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/DesignerFrame.java | 19 +++++++++++++++++-- .../actions/replace/ui/ITTableButton.java | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index a18cd724d..5040a5cbd 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -892,10 +892,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * activateJTemplate需要模板存在,openTemplate需要模板保存过,该方法模板保存与未保存皆可激活,模板如果关闭,并且保存过,会重新打开 * * @param templatePath 模板路径 template.getPath() - * @param templateName 模板名称 */ - public void openOrActiveTemplate(String templatePath, String templateName) { + public void openOrActiveTemplate(String templatePath) { //没保存过的模板如果要激活就要从当前历史模板列表里面找 + String templateName = getTemplateNameFromPath(templatePath); if (isTemplateNeverSaved(templatePath)) { int index = HistoryTemplateListCache.getInstance().contains(templateName); //如果历史模板列表中存在则激活 @@ -919,6 +919,21 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta 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; + } + + /** * 当前模板 停用失败 * diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java index 35ebedc72..c4cf47f59 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java @@ -46,7 +46,7 @@ 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().openOrActiveTemplate(content.getTemplatePath(), content.getTemplateName()); + DesignerContext.getDesignerFrame().openOrActiveTemplate(content.getTemplatePath()); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl); } ITReplaceMainDialog.setITReplaceFlag(false);