diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java index a3665b77b..15291211c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java @@ -5,6 +5,8 @@ import com.fr.base.io.XMLReadHelper; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.template.info.SendHelper; import com.fr.log.FineLoggerFactory; +import com.fr.stable.ProductConstants; +import com.fr.stable.StableUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLableReader; @@ -121,10 +123,23 @@ public abstract class AbstractPointCollector implem } } + + private File getInfoFile() { + File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), getInfoFilePath())); + try { + if (!file.exists()) { + StableUtils.makesureFileExist(file); + } + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + return file; + } + /** * 获取缓存文件存放路径 */ - protected abstract File getInfoFile(); + protected abstract String getInfoFilePath(); protected abstract void addIdleDayCount(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java index 04c4c80d3..87dc8ca40 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java @@ -8,15 +8,10 @@ import com.fr.design.mainframe.burying.point.AbstractPointCollector; import com.fr.design.mainframe.template.info.TemplateInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; -import com.fr.stable.ProductConstants; -import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; import com.fr.third.joda.time.DateTime; - -import java.io.File; import java.util.HashMap; import java.util.Map; @@ -235,16 +230,8 @@ public class ChartInfoCollector extends AbstractPointCollector { * 获取缓存文件存放路径 */ @Override - protected File getInfoFile() { - File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME)); - try { - if (!file.exists()) { - file.createNewFile(); - } - } catch (Exception ex) { - FineLoggerFactory.getLogger().error(ex.getMessage(), ex); - } - return file; + protected String getInfoFilePath() { + return XML_FILE_NAME; } @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java index 42e7acce6..23c07ea3a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java @@ -5,13 +5,10 @@ import com.fr.design.mainframe.burying.point.AbstractPointInfo; import com.fr.json.JSON; import com.fr.json.JSONFactory; import com.fr.json.JSONObject; -import com.fr.stable.ProductConstants; -import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; -import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -26,7 +23,7 @@ public class TemplateInfoCollector extends AbstractPointCollector private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList"; private static final String XML_FILE_NAME = "tpl.info"; private static TemplateInfoCollector instance; - private DesignerOpenHistory designerOpenHistory; + private DesignerOpenHistory designerOpenHistory = DesignerOpenHistory.getInstance(); //记录指定模板最新的模板耗时信息ID private Map latestTemplateInfo; @@ -99,14 +96,6 @@ public class TemplateInfoCollector extends AbstractPointCollector return latestTemplateInfo.getTemplateCreateTime(); } - /** - * 获取缓存文件存放路径 - */ - @Override - protected File getInfoFile() { - return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME)); - } - /** * 更新 day_count:打开设计器却未编辑模板的连续日子 */ @@ -172,6 +161,13 @@ public class TemplateInfoCollector extends AbstractPointCollector writer.end(); } + /** + * 获取缓存文件存放路径 + */ + @Override + protected String getInfoFilePath() { + return XML_FILE_NAME; + } @Override public void sendPointInfo() { diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java index 22d702dfd..7c852f282 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -111,7 +111,7 @@ public class XWAbsoluteLayout extends XLayoutContainer { private void initPercent(WAbsoluteLayout widget) { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension scrnsize = toolkit.getScreenSize(); - double screenValue = FRScreen.getByDimension(scrnsize).getValue(); + double screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue(); if (!AssistUtils.equals(screenValue, FormArea.DEFAULT_SLIDER)) { this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); } @@ -247,7 +247,7 @@ public class XWAbsoluteLayout extends XLayoutContainer { */ @Override public void updateChildBound(int minHeight) { - double prevContainerPercent = FRScreen.getByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER; + double prevContainerPercent = FRScreen.getDesignScreenByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER; if (toData().getCompState() == 0 && !AssistUtils.equals(containerPercent, prevContainerPercent)) { for (int i = 0; i < this.getComponentCount(); i++) { XCreator creator = getXCreator(i); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index 3fb0b5f96..352899bcb 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -72,7 +72,7 @@ public class XWFitLayout extends XLayoutContainer { private void initPercent(){ Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension scrnsize = toolkit.getScreenSize(); - double screenValue = FRScreen.getByDimension(scrnsize).getValue(); + double screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue(); if (!AssistUtils.equals(FormArea.DEFAULT_SLIDER, screenValue)) { this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); } @@ -1331,4 +1331,4 @@ public class XWFitLayout extends XLayoutContainer { } } } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/CoverReportPane.java b/designer-form/src/main/java/com/fr/design/mainframe/CoverReportPane.java index a6ec28abb..d976691c6 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/CoverReportPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/CoverReportPane.java @@ -63,7 +63,7 @@ public class CoverReportPane extends CoverPane implements HelpDialogHandler{ // controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_CLOSE_ICON_PATH); controlButton.setVisible(false); helpDialog = new WidgetHelpDialog(DesignerContext.getDesignerFrame(), helpMsg); - double screenValue = FRScreen.getByDimension(Toolkit.getDefaultToolkit().getScreenSize()).getValue(); + double screenValue = FRScreen.getDesignScreenByDimension(Toolkit.getDefaultToolkit().getScreenSize()).getValue(); int offsetX = 0; if (screenValue < FormArea.DEFAULT_SLIDER) { offsetX = (int) ((1 - screenValue / FormArea.DEFAULT_SLIDER) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java index ee1b1976c..fe692388b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java @@ -220,7 +220,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { private void initCalculateSize() { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension scrnsize = toolkit.getScreenSize(); - this.screenValue = FRScreen.getByDimension(scrnsize).getValue(); + this.screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue(); XLayoutContainer root = FormArea.this.designer.getRootComponent(); // 7.1.1不放缩放滑块,但表单大小仍按屏幕分辨率调整 // slidePane.populateBean(screenValue); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java b/designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java index 9ca2cdba9..d82bc1688 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java @@ -1,10 +1,13 @@ package com.fr.design.mainframe.template.info; +import com.fr.design.gui.core.WidgetOption; import com.fr.form.ui.ChartEditor; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WCardLayout; +import com.fr.general.ComparatorUtils; import com.fr.json.JSONObject; /** @@ -50,6 +53,11 @@ public abstract class ComponentOperate implements TemplateOperate { Widget { @Override protected boolean acceptType(Widget widget) { + for (WidgetOption widgetOption : WidgetOption.getFormWidgetIntance()) { + if (ComparatorUtils.equals(widget.getClass(), widgetOption.widgetClass())) { + return true; + } + } return false; } }, @@ -62,7 +70,7 @@ public abstract class ComponentOperate implements TemplateOperate { Absolute { @Override protected boolean acceptType(Widget widget) { - return widget.acceptType(WAbsoluteLayout.class); + return widget.acceptType(WAbsoluteLayout.class) && !widget.acceptType(WAbsoluteBodyLayout.class); } }; @@ -76,5 +84,14 @@ public abstract class ComponentOperate implements TemplateOperate { } return Widget; } + + public static boolean supportComponent(Widget widget) { + for (ComponentType componentType : values()) { + if (componentType.acceptType(widget)) { + return true; + } + } + return false; + } } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java b/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java index da64e78e4..c9f7d761e 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.template.info; import com.fr.base.iofile.attr.ExtendSharableAttrMark; + import com.fr.chart.chartattr.ChartCollection; import com.fr.form.FormElementCaseProvider; import com.fr.form.main.Form; @@ -21,6 +22,7 @@ import com.fr.report.cell.DefaultTemplateCellElement; import java.util.Iterator; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -61,12 +63,21 @@ public class JFormProcessInfo extends TemplateProcessInfo
{ // 获取模板控件数 public int getWidgetCount() { - int widgetCount = 0; - for (int i = 0; i < template.getContainer().getWidgetCount(); i++) { - WLayout wl = (WLayout) template.getContainer().getWidget(i); - widgetCount += wl.getWidgetCount(); - } - return widgetCount; + final AtomicInteger widgetCount = new AtomicInteger(); + Form.traversalWidget(this.template.getContainer(), new WidgetGather() { + @Override + public void dealWith(Widget widget) { + if (ComponentOperate.ComponentType.supportComponent(widget)) { + widgetCount.incrementAndGet(); + } + } + + @Override + public boolean dealWithAllCards() { + return true; + } + }, null); + return widgetCount.get(); } @Override @@ -167,7 +178,7 @@ public class JFormProcessInfo extends TemplateProcessInfo { public boolean useParaPane() { return this.template.getParaContainer() != null; } - + @Override public JSONArray getComponentsInfo() { JSONArray ja = new JSONArray(); @@ -177,10 +188,10 @@ public class JFormProcessInfo extends TemplateProcessInfo { this.componentProcessInfoMap.clear(); return ja; } - + @Override public JSONArray getReuseCmpList() { - + final JSONArray jo = JSONArray.create(); WLayout container = this.template.getContainer(); WidgetUtil.bfsTraversalWidget(container, new WidgetUtil.BfsWidgetGather() { @@ -197,7 +208,7 @@ public class JFormProcessInfo extends TemplateProcessInfo { }, AbstractBorderStyleWidget.class); return jo; } - + @Override public void updateTemplateOperationInfo(TemplateOperate templateOperate) { if (ComparatorUtils.equals(ComponentCreateOperate.OPERATE_TYPE, templateOperate.getOperateType())) { @@ -207,7 +218,7 @@ public class JFormProcessInfo extends TemplateProcessInfo { addComponentRemoveInfo(templateOperate.toJSONObject()); } } - + private void addComponentCreateInfo(JSONObject jsonObject) { String componentID = jsonObject.getString("componentID"); componentProcessInfoMap.put(componentID, jsonObject); diff --git a/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java b/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java index 1bebd0be7..2a6ec4ba6 100644 --- a/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java +++ b/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java @@ -1,9 +1,12 @@ package com.fr.design.mainframe.template.info; +import com.fr.form.ui.CardAddButton; +import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.ChartEditor; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.FreeButton; import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WCardLayout; import com.fr.json.JSONObject; @@ -35,4 +38,16 @@ public class ComponentCreateOperateTest { Assert.assertEquals(ComponentOperate.ComponentType.Absolute, ComponentOperate.ComponentType.parseType(new WAbsoluteLayout())); Assert.assertEquals(ComponentOperate.ComponentType.TabLayout, ComponentOperate.ComponentType.parseType(new WCardLayout())); } + + @Test + public void testSupportComponent() { + Assert.assertTrue(ComponentOperate.ComponentType.supportComponent(new FreeButton())); + Assert.assertTrue(ComponentOperate.ComponentType.supportComponent(new ElementCaseEditor())); + Assert.assertTrue(ComponentOperate.ComponentType.supportComponent(new ChartEditor())); + Assert.assertTrue(ComponentOperate.ComponentType.supportComponent(new WAbsoluteLayout())); + Assert.assertTrue(ComponentOperate.ComponentType.supportComponent(new WCardLayout())); + Assert.assertFalse(ComponentOperate.ComponentType.supportComponent(new CardSwitchButton())); + Assert.assertFalse(ComponentOperate.ComponentType.supportComponent(new CardAddButton())); + Assert.assertFalse(ComponentOperate.ComponentType.supportComponent(new WAbsoluteBodyLayout())); + } } diff --git a/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java b/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java index 4db78a271..2d25c64c9 100644 --- a/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java +++ b/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java @@ -6,6 +6,7 @@ import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.ChartEditor; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.FreeButton; +import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WCardLayout; @@ -146,4 +147,29 @@ public class JFormProcessInfoTest { ja = jFormProcessInfo.getComponentsInfo(); Assert.assertEquals(0, ja.size()); } + + @Test + public void testGetWidgetCount() { + Form form = new Form(); + WBorderLayout borderLayout = new WBorderLayout(); + form.setContainer(borderLayout); + WFitLayout fitLayout = new WFitLayout(); + borderLayout.addCenter(fitLayout); + fitLayout.addWidget(new FreeButton()); + fitLayout.addWidget(new ElementCaseEditor()); + JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); + Assert.assertEquals(2, jFormProcessInfo.getWidgetCount()); + + fitLayout.addWidget(new ChartEditor()); + Assert.assertEquals(3, jFormProcessInfo.getWidgetCount()); + + fitLayout.addWidget(new WAbsoluteBodyLayout()); + Assert.assertEquals(3, jFormProcessInfo.getWidgetCount()); + + fitLayout.addWidget(new CardSwitchButton()); + Assert.assertEquals(3, jFormProcessInfo.getWidgetCount()); + + fitLayout.addWidget(new ChartEditor()); + Assert.assertEquals(4, jFormProcessInfo.getWidgetCount()); + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java b/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java index 6f589b001..c23a03f1c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java @@ -101,6 +101,9 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo { for (int i = 0; i < columnLength; i++) { for (int j = 0; j < rowLength; j++) { TemplateCellElement templateCellElement = templateElementCase.getTemplateCellElement(i, j); + if (templateCellElement == null) { + continue; + } Object value = templateCellElement.getValue(); if (isTestCell(value, templateCellElement.getStyle())) { return true; @@ -129,20 +132,20 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo { } return parameterAttr.getParameterUI() != null; } - - + + @Override public JSONArray getComponentsInfo() { return new JSONArray(); } - + @Override public JSONArray getReuseCmpList() { return JSONArray.create(); } - + @Override public void updateTemplateOperationInfo(TemplateOperate templateOption) { - + } }