Browse Source

Pull request #4523: REPORT-53135 【智能联动】组件生成时,没有新增文案

Merge in DESIGN/design from ~HADES/design:feature/10.0 to feature/10.0

* commit '77076eae38ad4eff198b29a3ffb9b265830f4b16':
  REPORT-53135 漏交
  REPORT-53135 【智能联动】组件生成时,没有新增文案
feature/10.0
Hades 3 years ago
parent
commit
80dae438bd
  1. 28
      designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java
  2. 7
      designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java
  3. 5
      designer-base/src/main/java/com/fr/design/mod/ContentReplacer.java
  4. 4
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/JavaScriptContentReplacer.java
  5. 5
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/VanChartHtmlLabelContentReplacer.java
  6. 26
      designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java
  7. 13
      designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java

28
designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java

@ -9,6 +9,8 @@ import com.fr.data.SimpleDSColumn;
import com.fr.data.condition.FormulaCondition;
import com.fr.data.impl.FormulaDictionary;
import com.fr.data.impl.NameTableData;
import com.fr.design.mod.impl.repalce.JavaScriptContentReplacer;
import com.fr.design.mod.impl.repalce.VanChartHtmlLabelContentReplacer;
import com.fr.form.main.FormHyperlink;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.WidgetTitle;
@ -22,6 +24,7 @@ import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.cell.cellattr.core.group.FunctionGrouper;
import com.fr.report.cell.cellattr.core.group.SelectCount;
import com.fr.stable.Filter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@ -49,6 +52,8 @@ public class ContentObjectManager {
private final Set<String> set = new HashSet<>();
private final Map<String, ContentReplacer> map = new HashMap<>();
private ContentObjectManager() {
set.add(Formula.class.getName());
set.add(JavaScriptImpl.class.getName());
@ -70,6 +75,8 @@ public class ContentObjectManager {
set.add(SelectCount.class.getName());
set.add(WidgetTitle.class.getName());
set.add(FunctionGrouper.class.getName());
map.put(JavaScriptImpl.class.getName(), new JavaScriptContentReplacer());
map.put(VanChartHtmlLabel.class.getName(), new VanChartHtmlLabelContentReplacer());
}
public void searchObject(Object ob) {
@ -84,6 +91,9 @@ public class ContentObjectManager {
objectMap = ClassHelper.searchObject(ob, set, filter);
}
public void clearObject() {
if (objectMap != null) {
objectMap.clear();
}
objectMap = null;
}
@ -92,4 +102,22 @@ public class ContentObjectManager {
return objectMap;
}
public boolean needContentTip(Object ob, Set<String> nameSet) {
long start = System.currentTimeMillis();
objectMap = ClassHelper.searchObject(ob, set, ModClassFilter.getInstance());
for (Map.Entry<String, Set<Object>> entry : objectMap.entrySet()) {
for (Object o : entry.getValue()) {
for (String name : nameSet) {
ContentReplacer contentReplacer = map.get(entry.getKey());
if (contentReplacer!= null && contentReplacer.contain(o, name)) {
clearObject();
return true;
}
}
}
}
clearObject();
return false;
}
}

7
designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java

@ -168,5 +168,12 @@ public class ContentReplaceUtil {
return content;
}
public static boolean containsName(String content, String name) {
if (StringUtils.isNotEmpty(content)) {
return content.contains(name);
}
return false;
}
}

5
designer-base/src/main/java/com/fr/design/mod/ContentReplacer.java

@ -10,4 +10,9 @@ public interface ContentReplacer<T> {
void replace(T t, String oldName, String newName);
default boolean contain(T t, String name) {
return false;
}
}

4
designer-base/src/main/java/com/fr/design/mod/impl/repalce/JavaScriptContentReplacer.java

@ -19,4 +19,8 @@ public class JavaScriptContentReplacer implements ContentReplacer<JavaScriptImpl
}
}
@Override
public boolean contain(JavaScriptImpl javaScript, String name) {
return ContentReplaceUtil.containsName(javaScript.getContent(), name);
}
}

5
designer-base/src/main/java/com/fr/design/mod/impl/repalce/VanChartHtmlLabelContentReplacer.java

@ -19,4 +19,9 @@ public class VanChartHtmlLabelContentReplacer implements ContentReplacer<VanChar
ContentReplaceUtil.replaceContent(vanChartHtmlLabel.getCustomText(), oldName, newName));
}
}
@Override
public boolean contain(VanChartHtmlLabel vanChartHtmlLabel, String name) {
return ContentReplaceUtil.containsName(vanChartHtmlLabel.getCustomText(), name);
}
}

26
designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareGeneratePane.java

@ -1,5 +1,6 @@
package com.fr.design.share.ui.generate;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
@ -11,11 +12,14 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.share.Bean.ComponentGenerateInfo;
import com.fr.design.mainframe.share.action.ShareUIAspect;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.exception.LackOfValueException;
import com.fr.design.mainframe.share.generate.ComponentGeneratorCenter;
import com.fr.design.mainframe.share.select.ComponentTransformerFactory;
import com.fr.design.mod.ContentObjectManager;
import com.fr.form.share.exception.NetWorkFailedException;
import com.fr.form.share.group.DefaultShareGroup;
import com.fr.design.mainframe.share.util.ShareUIUtils;
@ -31,6 +35,8 @@ import com.fr.form.ui.Widget;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.util.HashSet;
import java.util.Set;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingWorker;
@ -100,8 +106,9 @@ public class ShareGeneratePane extends BasicPane {
JPanel pane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.mainPane = FRGUIPaneFactory.createCardLayout_S_Pane();
this.simplePane = new ShareMainPane(shareCover, rec, false, effectItemGroups);
this.uploadPane = new ShareMainPane(shareCover, rec, true, effectItemGroups);
boolean needContentTip = needContentTip();
this.simplePane = new ShareMainPane(shareCover, rec, false, effectItemGroups, needContentTip);
this.uploadPane = new ShareMainPane(shareCover, rec, true, effectItemGroups, needContentTip);
//暂时换一下,目前不用上传
this.mainPane.add(simplePane, ShareUIUtils.convertStateChange(ItemEvent.DESELECTED));
this.mainPane.add(uploadPane, ShareUIUtils.convertStateChange(ItemEvent.SELECTED));
@ -161,6 +168,21 @@ public class ShareGeneratePane extends BasicPane {
}
}
private boolean needContentTip() {
long start = System.currentTimeMillis();
XCreator xCreator = ComponentTransformerFactory.getInstance().transform(WidgetPropertyPane.getInstance().getEditingFormDesigner().getSelectionModel().getSelection()).getMiddle();
Set<XCreator> xCreators = new HashSet<>();
xCreator.traversalNameRelatedXCreators(xCreators);
Set<String> nameSet = new HashSet<>();
for (XCreator creator : xCreators) {
nameSet.add(creator.toData().getWidgetName());
}
boolean result = ContentObjectManager.getInstance().needContentTip(shareWidget, nameSet);
FineLoggerFactory.getLogger().debug("needContentTip spend {} ms", (System.currentTimeMillis() - start));
return result;
}
private JPanel createUploadCheckBox() {
JPanel panel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane();

13
designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java

@ -131,13 +131,15 @@ public class ShareMainPane extends JPanel {
private boolean upload;
private List<EffectItemGroup> effectItemGroups;
private final boolean needContentTip;
public ShareMainPane(Image shareCover, Rectangle rec, boolean upload, List<EffectItemGroup> effectItemGroups) {
public ShareMainPane(Image shareCover, Rectangle rec, boolean upload, List<EffectItemGroup> effectItemGroups, boolean needContentTip) {
this.shareCover = shareCover;
this.rec = rec;
this.upload = upload;
this.effectItemGroups = effectItemGroups;
this.needContentTip = needContentTip;
initCover(shareCover);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -174,7 +176,14 @@ public class ShareMainPane extends JPanel {
private JPanel createOverviewPane(boolean upload) {
JPanel componentPane = createComponentOverviewPane(upload);
String title = Toolkit.i18nText("Fine-Design_Share_Overview");
JPanel overviewPane = FRGUIPaneFactory.createTitledBorderPane(title);
JPanel overviewPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(title);
if (needContentTip) {
UILabel tipsLabel = ShareUIUtils.createTipsLabel(Toolkit.i18nText("Fine-Design_Share_Generate_Content_Tip"));
tipsLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
JPanel panel = new JPanel(FRGUIPaneFactory.createBorderLayout());
panel.add(tipsLabel);
overviewPane.add(panel, BorderLayout.NORTH);
}
overviewPane.add(componentPane, BorderLayout.CENTER);
return overviewPane;

Loading…
Cancel
Save