Browse Source

Pull request #5771: REPORT-59097 & REPORT-51919

Merge in DESIGN/design from ~STARRYI/design:release/11.0 to release/11.0

* commit '80af035ce63bd01f092556ce21ec0386d9c2226a':
  REPORT-51919 【主题切换】复用组件适配主题切换
  REPORT-59097 【主题切换】悬浮元素默认样式,应该是跟随主题的默认
fix-lag
starryi 3 years ago
parent
commit
835dbeb590
  1. 41
      designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedFloatElement.java
  2. 36
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  3. 36
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  4. 10
      designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentCreator.java
  5. 3
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java
  6. 9
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java
  7. 16
      designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java
  8. 3
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java
  9. 3
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/FormulaFloatAction.java
  10. 3
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java
  11. 3
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/TextBoxFloatAction.java

41
designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedFloatElement.java

@ -0,0 +1,41 @@
package com.fr.design.mainframe.theme.utils;
import com.fr.base.NameStyle;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import com.fr.report.cell.FloatElement;
import com.fr.stable.unit.UNIT;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/9/9
*/
public class DefaultThemedFloatElement {
public static FloatElement createInstance() {
return themingFloatElement(new FloatElement());
}
public static FloatElement createInstance(Object value) {
return themingFloatElement(new FloatElement(value));
}
public static FloatElement createInstance(UNIT leftDistance, UNIT topDistance, UNIT width, UNIT height, Object value) {
return themingFloatElement(new FloatElement(leftDistance, topDistance, width, height, value));
}
private static FloatElement themingFloatElement(FloatElement floatElement) {
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
TemplateTheme theme = template.getTemplateTheme();
ThemedCellStyle themedCellStyle = theme.getCellStyleList().getUse4Default();
if (themedCellStyle != null) {
NameStyle nameStyle = NameStyle.getPassiveInstance(themedCellStyle.getName(), themedCellStyle.getStyle());
floatElement.setStyle(nameStyle);
}
}
return floatElement;
}
}

36
designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java

@ -3,6 +3,11 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.base.theme.FineColorManager;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeAware;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.designer.creator.cardlayout.XCardAddButton; import com.fr.design.designer.creator.cardlayout.XCardAddButton;
import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; import com.fr.design.designer.creator.cardlayout.XCardSwitchButton;
@ -11,11 +16,15 @@ import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout; import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.ChartWidgetOptionProvider; import com.fr.design.fun.ChartWidgetOptionProvider;
import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.fun.ParameterWidgetOptionProvider; import com.fr.design.fun.ParameterWidgetOptionProvider;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.main.Form;
import com.fr.form.main.WidgetGather;
import com.fr.form.parameter.FormSubmitButton; import com.fr.form.parameter.FormSubmitButton;
import com.fr.form.ui.Button; import com.fr.form.ui.Button;
import com.fr.form.ui.CardAddButton; import com.fr.form.ui.CardAddButton;
@ -216,6 +225,16 @@ public class XCreatorUtils {
return xClazz; return xClazz;
} }
public static XCreator createThemedXCreator(Widget widget) {
XCreator creator = createXCreator(widget);
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
TemplateTheme theme = template.getTemplateTheme();
if (theme instanceof FormTheme) {
setupTemplateTheme(creator, (FormTheme) theme, TemplateThemeCompatible.NONE);
}
return creator;
}
/** /**
* 创建creator * 创建creator
* *
@ -356,4 +375,21 @@ public class XCreatorUtils {
} }
return null; return null;
} }
public static void setupTemplateTheme(XCreator container, final FormTheme currentTemplateUsingTheme, TemplateThemeCompatible compatible) {
FineColorManager.traverse(container.toData(), new FineColorManager.FineColorReplaceByTheme(currentTemplateUsingTheme, compatible));
Form.traversalWidget(container.toData(), new WidgetGather() {
@Override
public void dealWith(Widget widget) {
TemplateThemeAware<FormTheme> themedWidget = (TemplateThemeAware) widget;
themedWidget.onTemplateUsingThemeChange(currentTemplateUsingTheme, compatible);
}
@Override
public boolean dealWithAllCards() {
return true;
}
}, TemplateThemeAware.class);
}
} }

36
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1195,9 +1195,6 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
* @param xCreator 组件 * @param xCreator 组件
*/ */
public void startDraggingBean(XCreator xCreator) { public void startDraggingBean(XCreator xCreator) {
// 新疆的图表块和报表块默认主题化
addThemeToDroppedNewWidget(xCreator);
// 根据所选择的组件的BeanInfo生成相应的AddingModel // 根据所选择的组件的BeanInfo生成相应的AddingModel
// AddingModel和StateModel不一样,适合当前选择的组件相关的 // AddingModel和StateModel不一样,适合当前选择的组件相关的
addingModel = new AddingModel(this, xCreator); addingModel = new AddingModel(this, xCreator);
@ -1862,37 +1859,4 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
public FormSpacingLineDrawer getSpacingLineDrawer() { public FormSpacingLineDrawer getSpacingLineDrawer() {
return spacingLineDrawer; return spacingLineDrawer;
} }
private void addThemeToDroppedNewWidget(XCreator addingXCreator) {
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template == null) {
return;
}
TemplateTheme theme = template.getTemplateTheme();
if (!(theme instanceof FormTheme)) {
return;
}
FormTheme formTheme = (FormTheme) theme;
Form.traversalWidget(addingXCreator.toData(), new WidgetGather() {
@Override
public void dealWith(Widget widget) {
if (widget instanceof AbstractBorderStyleWidget) {
AbstractBorderStyleWidget styleWidget = (AbstractBorderStyleWidget) widget;
if (!styleWidget.supportThemed()) {
return;
}
boolean followingTheme = (!addingXCreator.isShared()) || styleWidget.isBorderStyleFollowingTheme();
styleWidget.setBorderStyleFollowingTheme(followingTheme);
if (followingTheme) {
styleWidget.onTemplateUsingThemeChange(formTheme, TemplateThemeCompatible.NONE);
}
}
}
@Override
public boolean dealWithAllCards() { return true; }
}, AbstractBorderStyleWidget.class);
addingXCreator.rebuid();
}
} }

10
designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentCreator.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe.share.generate.task;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.base.iofile.attr.ExtendSharableAttrMark; import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.base.iofile.attr.SharableAttrMark; import com.fr.base.iofile.attr.SharableAttrMark;
import com.fr.base.theme.TemplateTheme;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.share.generate.impl.AbstractComponentCreatorProcessor; import com.fr.design.mainframe.share.generate.impl.AbstractComponentCreatorProcessor;
@ -39,6 +40,8 @@ public class ComponentCreator extends AbstractComponentCreatorProcessor {
@Override @Override
public ComponentReuBean create(JTemplate<?, ?> jt, Map<String, Object> paraMap, Widget widget, DefaultSharableWidget info) throws Exception { public ComponentReuBean create(JTemplate<?, ?> jt, Map<String, Object> paraMap, Widget widget, DefaultSharableWidget info) throws Exception {
// 适用于共享组件的模版主题
setSuitableTemplateThemeName(jt, info);
// 遍历判断是否存在共享组件 // 遍历判断是否存在共享组件
checkOriginStatus(widget, info); checkOriginStatus(widget, info);
@ -56,6 +59,13 @@ public class ComponentCreator extends AbstractComponentCreatorProcessor {
return new ComponentReuBean(generatePath, editor, info); return new ComponentReuBean(generatePath, editor, info);
} }
private void setSuitableTemplateThemeName(JTemplate<?, ?> jt, DefaultSharableWidget info) {
TemplateTheme theme = jt.getTemplateTheme();
if (theme != null) {
info.setSuitableTemplateThemeName(theme.getName());
}
}
protected void checkOriginStatus(Widget widget, final DefaultSharableWidget info) { protected void checkOriginStatus(Widget widget, final DefaultSharableWidget info) {
Form.traversalWidget(widget, new WidgetGatherAdapter() { Form.traversalWidget(widget, new WidgetGatherAdapter() {

3
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java

@ -211,7 +211,8 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
creatorSource.setWidgetID(UUID.randomUUID().toString()); creatorSource.setWidgetID(UUID.randomUUID().toString());
((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); ((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true));
//tab布局WCardMainBorderLayout通过反射出来的大小是960*480 //tab布局WCardMainBorderLayout通过反射出来的大小是960*480
XCreator xCreator = ShareComponentUtils.createXCreator(creatorSource, shareId, no.getBindInfo()); String suitableTemplateThemeName = no.getWidget().getSuitableTemplateThemeName();
XCreator xCreator = ShareComponentUtils.createThemedXCreator(creatorSource, suitableTemplateThemeName, shareId, no.getBindInfo());
WidgetToolBarPane.getTarget().startDraggingBean(xCreator); WidgetToolBarPane.getTarget().startDraggingBean(xCreator);
lastPressEvent = null; lastPressEvent = null;
this.setBorder(null); this.setBorder(null);

9
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java

@ -12,6 +12,7 @@ import com.fr.design.login.DesignerLoginHelper;
import com.fr.design.login.DesignerLoginSource; import com.fr.design.login.DesignerLoginSource;
import com.fr.design.mainframe.WidgetToolBarPane; import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.share.collect.ComponentCollector; import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.form.share.DefaultSharableWidget;
import com.fr.form.share.group.DefaultShareGroup; import com.fr.form.share.group.DefaultShareGroup;
import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane; import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane;
import com.fr.design.mainframe.share.ui.online.OnlineWidgetRepoPane; import com.fr.design.mainframe.share.ui.online.OnlineWidgetRepoPane;
@ -143,7 +144,13 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true)); ((AbstractBorderStyleWidget) creatorSource).addWidgetAttrMark(new SharableAttrMark(true));
SharableWidgetProvider bindInfo = ShareUtils.getElCaseBindInfoById(shareId); SharableWidgetProvider bindInfo = ShareUtils.getElCaseBindInfoById(shareId);
//tab布局WCardMainBorderLayout通过反射出来的大小是960*480 //tab布局WCardMainBorderLayout通过反射出来的大小是960*480
XCreator xCreator = ShareComponentUtils.createXCreator(creatorSource, shareId, bindInfo); XCreator xCreator;
if (bindInfo instanceof DefaultSharableWidget) {
String suitableTemplateThemeName = ((DefaultSharableWidget) bindInfo).getSuitableTemplateThemeName();
xCreator = ShareComponentUtils.createThemedXCreator(creatorSource, suitableTemplateThemeName, shareId, bindInfo);
} else {
xCreator = ShareComponentUtils.createXCreator(creatorSource, shareId, bindInfo);
}
WidgetToolBarPane.getTarget().startDraggingBean(xCreator); WidgetToolBarPane.getTarget().startDraggingBean(xCreator);
lastPressEvent = null; lastPressEvent = null;
this.setBorder(null); this.setBorder(null);

16
designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java

@ -2,6 +2,9 @@ package com.fr.design.mainframe.share.util;
import com.fr.base.io.IOFile; import com.fr.base.io.IOFile;
import com.fr.base.iofile.attr.ExtendSharableAttrMark; import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.base.theme.FormTheme;
import com.fr.base.theme.TemplateTheme;
import com.fr.base.theme.TemplateThemeCompatible;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
@ -50,6 +53,19 @@ public class ShareComponentUtils {
return xCreator; return xCreator;
} }
public static XCreator createThemedXCreator(Widget creatorSource, String suitableTemplateThemeName, String shareId, SharableWidgetProvider provider) {
XCreator creator = createXCreator(creatorSource, shareId, provider);
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
TemplateTheme theme = template.getTemplateTheme();
if (theme instanceof FormTheme) {
boolean isCurrentUsingThemeSuitSharedComponent = StringUtils.isNotEmpty(theme.getName()) &&
StringUtils.isNotEmpty(suitableTemplateThemeName) &&
StringUtils.equals(theme.getName(), suitableTemplateThemeName);
XCreatorUtils.setupTemplateTheme(creator, (FormTheme) theme, isCurrentUsingThemeSuitSharedComponent ? TemplateThemeCompatible.NONE : TemplateThemeCompatible.ABSENT);
}
return creator;
}
/** /**
* 检查readme.txt文件 * 检查readme.txt文件
*/ */

3
designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java

@ -13,6 +13,7 @@ import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.theme.utils.DefaultThemedFloatElement;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.grid.Grid; import com.fr.grid.Grid;
@ -90,7 +91,7 @@ public class ChartFloatAction extends ElementCaseAction {
public void doOk() { public void doOk() {
isRecordNeeded = true; isRecordNeeded = true;
FloatElement newFloatElement; FloatElement newFloatElement;
newFloatElement = new FloatElement(chartDialog.getChartCollection()); newFloatElement = DefaultThemedFloatElement.createInstance(chartDialog.getChartCollection());
newFloatElement.setWidth(new OLDPIX(BaseChartCollection.CHART_DEFAULT_WIDTH)); newFloatElement.setWidth(new OLDPIX(BaseChartCollection.CHART_DEFAULT_WIDTH));
newFloatElement.setHeight(new OLDPIX(BaseChartCollection.CHART_DEFAULT_HEIGHT)); newFloatElement.setHeight(new OLDPIX(BaseChartCollection.CHART_DEFAULT_HEIGHT));

3
designer-realize/src/main/java/com/fr/design/actions/insert/flot/FormulaFloatAction.java

@ -14,6 +14,7 @@ import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.theme.utils.DefaultThemedFloatElement;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.grid.Grid; import com.fr.grid.Grid;
@ -99,7 +100,7 @@ public class FormulaFloatAction extends ElementCaseAction {
} }
reportPane.stopEditing(); reportPane.stopEditing();
final FloatElement floatElement = new FloatElement(); final FloatElement floatElement = DefaultThemedFloatElement.createInstance();
final UIFormula formulaPane = FormulaFactory.createFormulaPane(); final UIFormula formulaPane = FormulaFactory.createFormulaPane();
formulaPane.populate(BaseFormula.createFormulaBuilder().build()); formulaPane.populate(BaseFormula.createFormulaBuilder().build());

3
designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java

@ -12,6 +12,7 @@ import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.theme.utils.DefaultThemedFloatElement;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.report.SelectImagePane; import com.fr.design.report.SelectImagePane;
@ -73,7 +74,7 @@ public class ImageFloatAction extends ElementCaseAction {
reportPane.stopEditing(); reportPane.stopEditing();
final FloatElement floatElement = new FloatElement(); final FloatElement floatElement = DefaultThemedFloatElement.createInstance();
final SelectImagePane selectImagePane = new SelectImagePane(); final SelectImagePane selectImagePane = new SelectImagePane();
selectImagePane.populate(floatElement); selectImagePane.populate(floatElement);

3
designer-realize/src/main/java/com/fr/design/actions/insert/flot/TextBoxFloatAction.java

@ -6,6 +6,7 @@ package com.fr.design.actions.insert.flot;
import com.fr.base.DynamicUnitList; import com.fr.base.DynamicUnitList;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.theme.utils.DefaultThemedFloatElement;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.grid.Grid; import com.fr.grid.Grid;
@ -59,7 +60,7 @@ public class TextBoxFloatAction extends AbstractShapeAction {
if (jws == null) { if (jws == null) {
return; return;
} }
FloatElement floatElement = new FloatElement("Text"); FloatElement floatElement = DefaultThemedFloatElement.createInstance("Text");
this.startDraw(floatElement); this.startDraw(floatElement);
doWithDrawingFloatElement(); doWithDrawingFloatElement();
} }

Loading…
Cancel
Save