Browse Source

Merge branch 'release/10.0' of ssh://cloud.finedevelop.com:7999/~lanlan/design into release/10.0

feature/big-screen
Lanlan 5 years ago
parent
commit
163a09c001
  1. 5
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 5
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  3. 53
      designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardFilter.java
  4. 68
      designer-base/src/main/java/com/fr/design/base/clipboard/DesignerClipboard.java
  5. 34
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  6. 11
      designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java
  7. 5
      designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java
  8. 45
      designer-base/src/main/java/com/fr/design/fun/ClipboardHandlerProvider.java
  9. 7
      designer-base/src/main/java/com/fr/design/fun/FormAdaptiveConfigUIProcessor.java
  10. 17
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractClipboardHandlerProvider.java
  11. 25
      designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java
  12. 17
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java
  13. 17
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java
  14. 2
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  15. 98
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java
  16. 9
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java
  17. 101
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java
  18. 99
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java
  19. 20
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java
  20. 4
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  21. 5
      designer-base/src/main/java/com/fr/design/utils/DesignerPort.java
  22. 13
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
  23. 62
      designer-base/src/test/java/com/fr/design/base/clipboard/ClipboardFilterTest.java
  24. 75
      designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java
  25. 29
      designer-base/src/test/java/com/fr/design/base/clipboard/TestClipboardHandlerProvider.java
  26. 19
      designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java
  27. 13
      designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java
  28. 28
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  29. 10
      designer-form/src/main/java/com/fr/design/designer/creator/XButton.java
  30. 5
      designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java
  31. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  32. 2
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  33. 46
      designer-form/src/main/java/com/fr/design/form/util/FontTransformUtil.java
  34. 22
      designer-form/src/main/java/com/fr/design/fun/DesignerEditListenerProvider.java
  35. 17
      designer-form/src/main/java/com/fr/design/fun/impl/AbstractDesignerEditListenerProvider.java
  36. 2
      designer-form/src/main/java/com/fr/design/mainframe/CoverReportPane.java
  37. 2
      designer-form/src/main/java/com/fr/design/mainframe/FormArea.java
  38. 36
      designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java
  39. 24
      designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java
  40. 102
      designer-form/src/test/java/com/fr/design/designer/beans/models/SelectionModelTest.java
  41. 68
      designer-form/src/test/java/com/fr/design/form/util/FontTransformUtilTest.java
  42. 52
      designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java
  43. 30
      designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java
  44. 14
      designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java
  45. 10
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  46. 7
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java
  47. 15
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java
  48. 3
      designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java
  49. 3
      designer-realize/src/main/java/com/fr/design/report/RichTextPane.java
  50. 5
      designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java

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

@ -58,6 +58,7 @@ import javax.swing.SwingWorker.StateValue;
import java.awt.Color; import java.awt.Color;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FileReader; import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
@ -206,9 +207,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
GeneralContext.setLocale(designerEnvManager.getLanguage()); GeneralContext.setLocale(designerEnvManager.getLanguage());
try { try {
XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile()); XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile());
} catch (Exception e) { } catch (FileNotFoundException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
XmlHandler.Self.handle(e); XmlHandler.Self.handle(e);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
// james:如果没有env定义,要设置一个默认的 // james:如果没有env定义,要设置一个默认的

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

@ -415,10 +415,7 @@ public class EnvChangeEntrance {
@Override @Override
public void doOk() { public void doOk() {
ProcessEventPipe pipe = FineProcessContext.getParentPipe(); FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.ACTIVE.getValue()));
if (FineProcessContext.getParentPipe() != null) {
pipe.fire(new CarryMessageEvent(ReportState.ACTIVE.getValue()));
}
if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { if (!envListOkAction(envListPane, PopTipStrategy.NOW)) {
DesignerExiter.getInstance().execute(); DesignerExiter.getInstance().execute();
} }

53
designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardFilter.java

@ -0,0 +1,53 @@
package com.fr.design.base.clipboard;
import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.form.main.ExtraFormClassManager;
import com.fr.plugin.injectable.PluginModule;
import java.util.Set;
/**
* created by Harrison on 2020/05/14
**/
@SuppressWarnings({"rawtypes", "unchecked"})
public abstract class ClipboardFilter {
public static <T> T cut(T selection) {
Class<?> clazz = selection.getClass();
ExtraFormClassManager manager = PluginModule.getAgent(PluginModule.ExtraForm);
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG);
for (ClipboardHandlerProvider provider : providers) {
if (provider.support(clazz)) {
selection = ((ClipboardHandlerProvider<T>) provider).cut(selection);
}
}
return selection;
}
public static <T> T copy(T selection) {
Class<?> clazz = selection.getClass();
ExtraFormClassManager manager = PluginModule.getAgent(PluginModule.ExtraForm);
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG);
for (ClipboardHandlerProvider provider : providers) {
if (provider.support(clazz)) {
selection = ((ClipboardHandlerProvider<T>) provider).copy(selection);
}
}
return selection;
}
public static <T> T paste(T selection) {
Class<?> clazz = selection.getClass();
ExtraFormClassManager manager = PluginModule.getAgent(PluginModule.ExtraForm);
Set<ClipboardHandlerProvider> providers = manager.getArray(ClipboardHandlerProvider.XML_TAG);
for (ClipboardHandlerProvider provider : providers) {
if (provider.support(clazz)) {
selection = ((ClipboardHandlerProvider<T>) provider).paste(selection);
}
}
return selection;
}
}

68
designer-base/src/main/java/com/fr/design/base/clipboard/DesignerClipboard.java

@ -0,0 +1,68 @@
package com.fr.design.base.clipboard;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.FlavorListener;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
/**
* created by Harrison on 2020/05/11
**/
public class DesignerClipboard extends Clipboard {
private Clipboard clipboard;
public DesignerClipboard(Clipboard clipboard) {
super(clipboard.getName());
this.clipboard = clipboard;
}
@Override
public synchronized void setContents(Transferable contents, ClipboardOwner owner) {
//处理 contents/owner
Transferable filtered = ClipboardFilter.copy(contents);
clipboard.setContents(filtered, owner);
}
@Override
public synchronized Transferable getContents(Object requestor) {
Transferable contents = clipboard.getContents(requestor);
//处理 contents
Transferable filtered = ClipboardFilter.paste(contents);
return filtered;
}
@Override
public DataFlavor[] getAvailableDataFlavors() {
return clipboard.getAvailableDataFlavors();
}
@Override
public boolean isDataFlavorAvailable(DataFlavor flavor) {
return clipboard.isDataFlavorAvailable(flavor);
}
@Override
public Object getData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
return clipboard.getData(flavor);
}
@Override
public synchronized void addFlavorListener(FlavorListener listener) {
clipboard.addFlavorListener(listener);
}
@Override
public synchronized void removeFlavorListener(FlavorListener listener) {
clipboard.removeFlavorListener(listener);
}
@Override
public synchronized FlavorListener[] getFlavorListeners() {
return clipboard.getFlavorListeners();
}
}

34
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java

@ -1,12 +1,10 @@
package com.fr.design.data.datapane; package com.fr.design.data.datapane;
import com.fr.base.BaseUtils;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.data.core.DataCoreUtils; import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.TableProcedure;
import com.fr.data.core.db.dialect.DialectFactory; import com.fr.data.core.db.dialect.DialectFactory;
import com.fr.data.impl.Connection;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
@ -37,6 +35,7 @@ import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.connection.DBConnectAuth;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -61,9 +60,10 @@ import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Set;
/** /**
* @author zhou * @author zhou
@ -210,10 +210,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected void initDsNameComboBox() { protected void initDsNameComboBox() {
dsNameComboBox.setRefreshingModel(true); dsNameComboBox.setRefreshingModel(true);
ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(getHasAuthConnections());
List<String> dsList = new ArrayList<>();
dsList.addAll(connectionConfig.getConnections().keySet());
FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(dsList);
dsNameComboBox.setModel(dsNameComboBoxModel); dsNameComboBox.setModel(dsNameComboBoxModel);
dsNameComboBox.setRefreshingModel(false); dsNameComboBox.setRefreshingModel(false);
} }
@ -322,14 +319,31 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
return null; // peter:选中了当前的零长度的节点,直接返回. return null; // peter:选中了当前的零长度的节点,直接返回.
} }
ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); ConnectionConfig connectionConfig = ConnectionConfig.getInstance();
for (Map.Entry<String, Connection> entry : connectionConfig.getConnections().entrySet()) { List<String> authConnections = getHasAuthConnections();
if (ComparatorUtils.equals(selectedDSName, entry.getKey())) { for (String name : authConnections) {
return entry.getValue(); if (ComparatorUtils.equals(selectedDSName, name)) {
return connectionConfig.getConnection(name);
} }
} }
return null; return null;
} }
private List<String> getHasAuthConnections() {
List<String> authConnections = new ArrayList<>();
Set<String> allConnections = ConnectionConfig.getInstance().getConnections().keySet();
Collection<String> noAuthConnections = WorkContext.getCurrent().get(DBConnectAuth.class).getNoAuthConnections();
if (noAuthConnections == null) {
return authConnections;
}
for (String name : allConnections) {
if (!noAuthConnections.contains(name)) {
authConnections.add(name);
}
}
return authConnections;
}
/** /**
* 刷新没多大用而且要刷新也不是这儿刷新 * 刷新没多大用而且要刷新也不是这儿刷新
*/ */

11
designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java

@ -2,6 +2,7 @@ package com.fr.design.data.datapane;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.impl.RecursionTableData; import com.fr.data.impl.RecursionTableData;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper; import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
@ -70,8 +71,14 @@ public class TreeTableDataComboBox extends UIComboBox {
} }
public void setSelectedTableDataByName(String name) { public void setSelectedTableDataByName(String name) {
TableDataWrapper tableDataWrappe = res_map.get(name); TableDataWrapper tableDataWrapper;
this.getModel().setSelectedItem(tableDataWrappe); if (res_map.get(name) != null) {
tableDataWrapper = res_map.get(name);
} else {
String changeName = DesignTableDataManager.getChangedDsNameByOldDsName(name);
tableDataWrapper = res_map.get(changeName);
}
this.getModel().setSelectedItem(tableDataWrapper);
} }
@Override @Override

5
designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java vendored

@ -72,10 +72,7 @@ public class DesignerWorkspaceGenerator {
enum RemoteHandler { enum RemoteHandler {
SELF; SELF;
public static void handle(DesignerWorkspaceInfo config) { public static void handle(DesignerWorkspaceInfo config) {
ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.STOP.getValue()));
if (eventPipe != null) {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
}
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getId(), StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getId(),
DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getMessage(), DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getMessage(),
StringUtils.EMPTY); StringUtils.EMPTY);

45
designer-base/src/main/java/com/fr/design/fun/ClipboardHandlerProvider.java

@ -0,0 +1,45 @@
package com.fr.design.fun;
import com.fr.stable.fun.mark.Mutable;
/**
* created by Harrison on 2020/05/14
**/
public interface ClipboardHandlerProvider<T> extends Mutable {
String XML_TAG = "ClipboardHandlerProvider";
int CURRENT_LEVEL = 1;
/**
* 剪切
*
* @param selection 选中
* @return 处理后的内容
*/
T cut(T selection);
/**
* 复制
*
* @param selection 选中
* @return 处理后的内容
*/
T copy(T selection);
/**
* 粘贴
*
* @param selection 选中
* @return 处理后的内容
*/
T paste(T selection);
/**
* 支持的类型
*
* @param selection 内容
* @return 是否
*/
boolean support(Object selection);
}

7
designer-base/src/main/java/com/fr/design/fun/FormAdaptiveConfigUIProcessor.java

@ -32,5 +32,12 @@ public interface FormAdaptiveConfigUIProcessor extends Immutable {
*/ */
BufferedImage paintFormElementCaseImage(Dimension size, JComponent elementCasePane); BufferedImage paintFormElementCaseImage(Dimension size, JComponent elementCasePane);
/**
* 获取新自适应下字体显示的dpi
* @return dpi
*/
int fontResolution();
} }

17
designer-base/src/main/java/com/fr/design/fun/impl/AbstractClipboardHandlerProvider.java

@ -0,0 +1,17 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
/**
* created by Harrison on 2020/05/14
**/
@API(level = ClipboardHandlerProvider.CURRENT_LEVEL)
public abstract class AbstractClipboardHandlerProvider<T> extends AbstractProvider implements ClipboardHandlerProvider<T> {
@Override
public int currentAPILevel() {
return ClipboardHandlerProvider.CURRENT_LEVEL;
}
}

25
designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java

@ -4,6 +4,7 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.base.clipboard.DesignerClipboard;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -62,10 +63,24 @@ public class DesignerContext {
} }
/** /**
* Gets the Clipboard. * get this custom clipboard
*/ */
public static Clipboard getClipboard(JComponent comp) { public static Clipboard getClipboard(JComponent comp) {
if (DesignerContext.clipboard == null) { if (DesignerContext.clipboard == null) {
Clipboard clipboard = getClipboard0(comp);
return new DesignerClipboard(clipboard);
}
return DesignerContext.clipboard;
}
/**
* Gets the system Clipboard.
*/
private static Clipboard getClipboard0(JComponent comp) {
Clipboard clipboard = null;
try { try {
Action transferAction = TransferHandler.getCutAction(); Action transferAction = TransferHandler.getCutAction();
Method clipMethod = StableUtils.getDeclaredMethod(transferAction.getClass(), "getClipboard", new Class[]{JComponent.class}); Method clipMethod = StableUtils.getDeclaredMethod(transferAction.getClass(), "getClipboard", new Class[]{JComponent.class});
@ -78,15 +93,13 @@ public class DesignerContext {
//这样可以保证和TextField直接的copy paste //这样可以保证和TextField直接的copy paste
try { try {
//控件的Clipboard. //控件的Clipboard.
DesignerContext.clipboard = comp.getToolkit().getSystemClipboard(); clipboard = comp.getToolkit().getSystemClipboard();
} catch (Exception exp) { } catch (Exception exp) {
FineLoggerFactory.getLogger().error(exp.getMessage(), exp); FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
DesignerContext.clipboard = new Clipboard("FR"); clipboard = new Clipboard("FR");
} }
} }
} return clipboard;
return DesignerContext.clipboard;
} }

17
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.DesignerEnvManager;
import com.fr.design.mainframe.template.info.SendHelper; import com.fr.design.mainframe.template.info.SendHelper;
import com.fr.log.FineLoggerFactory; 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.XMLPrintWriter;
import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
@ -121,10 +123,23 @@ public abstract class AbstractPointCollector<T extends AbstractPointInfo> 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(); protected abstract void addIdleDayCount();
} }

17
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.TemplateInfo;
import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.general.ComparatorUtils; 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.StringUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.joda.time.DateTime; import com.fr.third.joda.time.DateTime;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -235,16 +230,8 @@ public class ChartInfoCollector extends AbstractPointCollector<ChartInfo> {
* 获取缓存文件存放路径 * 获取缓存文件存放路径
*/ */
@Override @Override
protected File getInfoFile() { protected String getInfoFilePath() {
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME)); return XML_FILE_NAME;
try {
if (!file.exists()) {
file.createNewFile();
}
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return file;
} }
@Override @Override

2
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -45,7 +45,7 @@ public class DesignerLogHandler {
private final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static final int GAP_X = -150; private static final int GAP_X = -75;
private static final int INFO_GAP_Y = -60; private static final int INFO_GAP_Y = -60;

98
designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java

@ -2,13 +2,16 @@ package com.fr.design.mainframe.loghandler;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.ui.util.UIUtil;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.fr.design.i18n.Toolkit.i18nText;
public class LogHandlerBar extends JPanel implements ItemSelectable { public class LogHandlerBar extends JPanel implements ItemSelectable {
@ -17,11 +20,16 @@ public class LogHandlerBar extends JPanel implements ItemSelectable {
private UIButton clear; private UIButton clear;
private UIButton selectedall; private UIButton selectedall;
private UIButton set; private UIButton set;
private UILabel normalLabel;
private UILabel alertLabel;
private UILabel seriouslyLabel;
private String text; private String text;
private int INFONUM = 0; private int INFONUM = 0;
private int ERRORNUM = 0; private int ERRORNUM = 0;
private int SERVERNUM = 0; private int SERVERNUM = 0;
private static final int FLOW_LAYOUT_HGAP = 10;
private static final int FLOW_LAYOUT_VGAP = 5;
private boolean isWithSerious; private boolean isWithSerious;
@ -30,33 +38,53 @@ public class LogHandlerBar extends JPanel implements ItemSelectable {
} }
public LogHandlerBar(String text) { public LogHandlerBar(String text) {
this.setLayout(new CaptionLayout()); this.setLayout(new FlowLayout(FlowLayout.RIGHT, FLOW_LAYOUT_HGAP, FLOW_LAYOUT_VGAP));
this.setUI(new LogHandlerBarUI()); this.setUI(new LogHandlerBarUI());
this.text = text; this.text = text;
clear = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/clear.png")); clear = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/clear.png"));
clear.setMargin(null); clear.setMargin(null);
clear.setOpaque(false); clear.setOpaque(false);
clear.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); clear.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
clear.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_All")); clear.setToolTipText(i18nText("Fine-Design_Basic_Clear_All"));
selectedall = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/selectedall.png")); selectedall = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/selectedall.png"));
selectedall.setMargin(null); selectedall.setMargin(null);
selectedall.setOpaque(false); selectedall.setOpaque(false);
selectedall.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); selectedall.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
selectedall.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_All")); selectedall.setToolTipText(i18nText("Fine-Design_Basic_Select_All"));
set = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/setting.png")); set = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/setting.png"));
set.setMargin(null); set.setMargin(null);
set.setOpaque(false); set.setOpaque(false);
set.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); set.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
set.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set")); set.setToolTipText(i18nText("Fine-Design_Report_Set"));
normalLabel = new UILabel(i18nText("Fine-Design_Basic_NNormal") + "(0)");
alertLabel = new UILabel(i18nText("Fine-Design_Basic_Alert") + "(0)");
seriouslyLabel = new UILabel(i18nText("Fine-Design_Basic_Seriously") + "(0)");
this.add(normalLabel);
this.add(alertLabel);
this.add(seriouslyLabel);
this.add(clear); this.add(clear);
this.add(selectedall); this.add(selectedall);
this.add(set); this.add(set);
} }
/**
* 更新日志数量统计标签
*/
private void changeLabel() {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
normalLabel.setText(i18nText("Fine-Design_Basic_NNormal") + '(' + getInfo() + ')');
alertLabel.setText(i18nText("Fine-Design_Basic_Alert") + '(' + getError() + ')');
seriouslyLabel.setText(i18nText("Fine-Design_Basic_Seriously") + '(' + getServer() + ')');
}
});
}
public void clearMessage() { public void clearMessage() {
INFONUM = ERRORNUM = SERVERNUM = 0; INFONUM = ERRORNUM = SERVERNUM = 0;
repaint(); changeLabel();
} }
public boolean IsWithSerious() { public boolean IsWithSerious() {
@ -69,27 +97,17 @@ public class LogHandlerBar extends JPanel implements ItemSelectable {
public void infoAdd() { public void infoAdd() {
INFONUM++; INFONUM++;
repaint(); changeLabel();
} }
public void errorAdd() { public void errorAdd() {
ERRORNUM++; ERRORNUM++;
timerPaint(); changeLabel();
} }
public void serverAdd() { public void serverAdd() {
SERVERNUM++; SERVERNUM++;
timerPaint(); changeLabel();
}
private AtomicBoolean painting = new AtomicBoolean(false);
public void timerPaint() {
if(!painting.get()) {
painting.set(true);
repaint();
painting.set(false);
}
} }
public int getInfo() { public int getInfo() {
@ -141,44 +159,4 @@ public class LogHandlerBar extends JPanel implements ItemSelectable {
public void addSetListener(ActionListener l) { public void addSetListener(ActionListener l) {
set.addActionListener(l); set.addActionListener(l);
} }
private class CaptionLayout implements LayoutManager {
@Override
public void addLayoutComponent(String name, Component comp) {
}
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return new Dimension(120, 24);
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return new Dimension(0, 0);
}
@Override
public void layoutContainer(Container target) {
Insets insets = target.getInsets();
int top = insets.top;
int right = target.getWidth() - insets.right;
clear.setBounds(right - CLEAR_OFFSET, top + TOP_OFFSET, clear.getPreferredSize().width, clear.getPreferredSize().height);
selectedall.setBounds(right - SELECT_OFFSET, top + TOP_OFFSET, selectedall.getPreferredSize().width, selectedall.getPreferredSize().height);
set.setBounds(right - SET_OFFSET, top + TOP_OFFSET, set.getPreferredSize().width, set.getPreferredSize().height);
}
private static final int CLEAR_OFFSET = 130;
private static final int TOP_OFFSET = 4;
private static final int SELECT_OFFSET = 100;
private static final int SET_OFFSET = 70;
}
} }

9
designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java

@ -1,5 +1,7 @@
package com.fr.design.mainframe.loghandler; package com.fr.design.mainframe.loghandler;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.FontMetrics; import java.awt.FontMetrics;
@ -11,9 +13,6 @@ import java.awt.event.FocusListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
public class LogHandlerBarUI extends ComponentUI implements MouseListener, FocusListener { public class LogHandlerBarUI extends ComponentUI implements MouseListener, FocusListener {
@ -99,10 +98,6 @@ public class LogHandlerBarUI extends ComponentUI implements MouseListener, Focus
if (button.getText() != null) { if (button.getText() != null) {
g.drawString(button.getText(), textLeadingGap, y); g.drawString(button.getText(), textLeadingGap, y);
} }
g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_NNormal") + '(' + button.getInfo() + ')', button.getWidth() - 310, y);
g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + '(' + button.getError() + ')', button.getWidth() - 250, y);
g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + '(' + button.getServer() + ')', button.getWidth() - 190, y);
} }
/** /**

101
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java

@ -2,29 +2,53 @@ package com.fr.design.mainframe.mobile.ui;
import com.fr.base.background.ColorBackground; import com.fr.base.background.ColorBackground;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.color.ColorSelectBox; import com.fr.design.style.color.ColorSelectBox;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle; import com.fr.form.ui.mobile.MobileStyle;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.stable.Constants;
import javax.swing.*; import javax.swing.JPanel;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{
Constants.LINE_NONE,
Constants.LINE_THIN, //1px
Constants.LINE_MEDIUM, //2px
Constants.LINE_THICK, //3px
};
private static final int NORMAL_COMBO_WIDTH = 152;
private Widget widget; private Widget widget;
private MobileStyleCustomDefinePane customBeanPane; private MobileStyleCustomDefinePane customBeanPane;
private Class<? extends MobileStyle> mobileStyleClazz; private Class<? extends MobileStyle> mobileStyleClazz;
private ColorSelectBox colorSelectBox; private ColorSelectBox colorSelectBox;
private Color titleColor = new Color(47, 142, 241); private Color titleColor = new Color(47, 142, 241);
private JPanel commomPane;
private LineComboBox borderType;
private NewColorSelectBox borderColor;
private UISpinner borderRadius;
private MobileStyleFontConfigPane fontConfigPane;
MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass, MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass,
Class<? extends MobileStyle> mobileStyleClazz) { Class<? extends MobileStyle> mobileStyleClazz) {
@ -40,6 +64,14 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
if(ob.getBackground() != null) { if(ob.getBackground() != null) {
colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor()); colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor());
} }
borderType.setSelectedLineStyle(ob.getBorderType());
if (ob.getBorderColor() != null) {
borderColor.setSelectObject(ob.getBorderColor());
}
borderRadius.setValue(ob.getBorderRadius());
if (ob.getFont() != null) {
fontConfigPane.populateBean(ob.getFont());
}
} }
@Override @Override
@ -48,6 +80,10 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
this.widget.setMobileStyle(mobileStyle); this.widget.setMobileStyle(mobileStyle);
this.customBeanPane.updateBean(); this.customBeanPane.updateBean();
mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject())); mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject()));
mobileStyle.setBorderType(borderType.getSelectedLineStyle());
mobileStyle.setBorderColor(borderColor.getSelectObject());
mobileStyle.setBorderRadius(borderRadius.getValue());
mobileStyle.setFont(fontConfigPane.updateBean());
return mobileStyle; return mobileStyle;
} }
@ -64,7 +100,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private void createGeneralPane() { private void createGeneralPane() {
createPreviewPane(); createPreviewPane();
createBackgroundPane(); createCommonPane();
} }
private void createPreviewPane() { private void createPreviewPane() {
@ -79,29 +115,49 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
} }
} }
private void createBackgroundPane() { private void createCommonPane() {
JPanel backgroundPane = new JPanel();
backgroundPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5));
backgroundPane.setPreferredSize(new Dimension(500, 65));
TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute")); TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute"));
backgroundPane.setBorder(titledBorder); commomPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
commomPane.setBorder(titledBorder);
this.add(commomPane, BorderLayout.NORTH);
UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT); createBackgroundPane();
colorSelectLabel.setPreferredSize(new Dimension(65, 20)); createBorderPane();
createFontPane();
}
colorSelectBox = new ColorSelectBox(152); private void createBackgroundPane() {
colorSelectBox = new ColorSelectBox(NORMAL_COMBO_WIDTH);
colorSelectBox.addSelectChangeListener(new ChangeListener() { colorSelectBox.addSelectChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
} }
}); });
backgroundPane.add(colorSelectLabel); JPanel backgroundPane = createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Background")), colorSelectBox);
backgroundPane.add(colorSelectBox); commomPane.add(backgroundPane);
}
this.add(backgroundPane, BorderLayout.NORTH); private void createBorderPane() {
borderType = new LineComboBox(BORDER_LINE_STYLE_ARRAY);
borderType.setSelectedLineStyle(Constants.LINE_THIN);
borderType.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 15, 20));
borderColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
borderColor.addSelectChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2);
borderRadius.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 20, 20));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderType")), borderType));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColor));
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius));
}
private void createFontPane() {
fontConfigPane = new MobileStyleFontConfigPane();
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane));
} }
private void createCustomPane() { private void createCustomPane() {
@ -109,6 +165,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Set")); TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Set"));
configPane.setBorder(titledBorder); configPane.setBorder(titledBorder);
JPanel container = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
configPane.add(this.customBeanPane, BorderLayout.CENTER); configPane.add(this.customBeanPane, BorderLayout.CENTER);
this.add(configPane, BorderLayout.CENTER); this.add(configPane, BorderLayout.CENTER);
@ -119,4 +176,14 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12)); titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12));
return titledBorder; return titledBorder;
} }
private UILabel createConfigLabel(String title) {
UILabel label = new UILabel(title + ":", UILabel.RIGHT);
label.setPreferredSize(new Dimension(75, 20));
return label;
}
private JPanel createLeftRightComponentsPane(Component... components) {
return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{components}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
}
} }

99
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java

@ -0,0 +1,99 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.stable.Constants;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.Vector;
public class MobileStyleFontConfigPane extends JPanel {
private static final int MAX_FONT_SIZE = 18;
private static final int MIN_FONT_SIZE = 12;
private static final Dimension BUTTON_SIZE = new Dimension(20, 18);
public static Vector<Integer> getFontSizes() {
Vector<Integer> FONT_SIZES = new Vector<Integer>();
for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) {
FONT_SIZES.add(i);
}
return FONT_SIZES;
}
private UIComboBox fontSizeComboBox;
private UIToggleButton underline;
private UIToggleButton italic;
private UIToggleButton bold;
public MobileStyleFontConfigPane() {
this.initComponent();
}
private void initComponent() {
fontSizeComboBox = new UIComboBox(getFontSizes());
fontSizeComboBox.setSelectedItem(16);
fontSizeComboBox.setPreferredSize(new Dimension(60, 20));
fontSizeComboBox.setEditable(true);
underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png"));
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
this.setButtonsTips();
this.setButtonsSize(BUTTON_SIZE);
Component[] components_font = new Component[]{
fontSizeComboBox, underline, italic, bold
};
JPanel buttonPane = new JPanel(new BorderLayout());
buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE));
this.setLayout(new BorderLayout(0,0));
this.add(buttonPane, BorderLayout.CENTER);
}
private void setButtonsTips() {
underline.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Underline"));
italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Italic"));
bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bold"));
}
private void setButtonsSize(Dimension size) {
underline.setPreferredSize(size);
italic.setPreferredSize(size);
bold.setPreferredSize(size);
}
public void populateBean(FRFont frFont) {
fontSizeComboBox.setSelectedItem(frFont.getSize());
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
underline.setSelected(frFont.getUnderline() != Constants.LINE_NONE);
}
public FRFont updateBean() {
int style = Font.PLAIN;
style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN;
style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN;
return FRFont.getInstance(
FRFont.DEFAULT_FONTNAME,
style,
Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()),
Color.BLACK,
underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE
);
}
}

20
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.JSON;
import com.fr.json.JSONFactory; import com.fr.json.JSONFactory;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -26,7 +23,7 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList"; private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList";
private static final String XML_FILE_NAME = "tpl.info"; private static final String XML_FILE_NAME = "tpl.info";
private static TemplateInfoCollector instance; private static TemplateInfoCollector instance;
private DesignerOpenHistory designerOpenHistory; private DesignerOpenHistory designerOpenHistory = DesignerOpenHistory.getInstance();
//记录指定模板最新的模板耗时信息ID //记录指定模板最新的模板耗时信息ID
private Map<String, Long> latestTemplateInfo; private Map<String, Long> latestTemplateInfo;
@ -99,14 +96,6 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
return latestTemplateInfo.getTemplateCreateTime(); return latestTemplateInfo.getTemplateCreateTime();
} }
/**
* 获取缓存文件存放路径
*/
@Override
protected File getInfoFile() {
return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME));
}
/** /**
* 更新 day_count打开设计器却未编辑模板的连续日子 * 更新 day_count打开设计器却未编辑模板的连续日子
*/ */
@ -172,6 +161,13 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
writer.end(); writer.end();
} }
/**
* 获取缓存文件存放路径
*/
@Override
protected String getInfoFilePath() {
return XML_FILE_NAME;
}
@Override @Override
public void sendPointInfo() { public void sendPointInfo() {

4
designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

@ -291,10 +291,8 @@ public class DesignUtils {
if (isDisplaySimSun(defaultLocale)) { if (isDisplaySimSun(defaultLocale)) {
guiFRFont = getNamedFont("SimSun"); guiFRFont = getNamedFont("SimSun");
} else if (isDisplayDialog(defaultLocale)) {
guiFRFont = getNamedFont("Dialog");
} else { } else {
guiFRFont = getNamedFont("Tahoma"); guiFRFont = getNamedFont("Dialog");
} }
//先初始化的设计器locale, 后初始化lookandfeel.如果顺序改了, 这边也要调整. //先初始化的设计器locale, 后初始化lookandfeel.如果顺序改了, 这边也要调整.

5
designer-base/src/main/java/com/fr/design/utils/DesignerPort.java

@ -90,10 +90,7 @@ public class DesignerPort implements XMLReadable, XMLWriter {
} }
public void resetPort() { public void resetPort() {
ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.STOP.getValue()));
if (eventPipe != null) {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
}
TipDialog dialog = new TipDialog(null, TipDialog dialog = new TipDialog(null,
StringUtils.EMPTY, StringUtils.EMPTY,
Toolkit.i18nText("Fine-Design_Port_Found_Port_Conflict"), Toolkit.i18nText("Fine-Design_Port_Found_Port_Conflict"),

13
designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java

@ -62,6 +62,7 @@ public class FineEmbedServerActivator extends Activator {
tomcat.setPort(DesignerEnvManager.getEnvManager().getEmbedServerPort()); tomcat.setPort(DesignerEnvManager.getEnvManager().getEmbedServerPort());
// 设置解码uri使用的字符编码 // 设置解码uri使用的字符编码
tomcat.getConnector().setURIEncoding(EncodeConstants.ENCODING_UTF_8); tomcat.getConnector().setURIEncoding(EncodeConstants.ENCODING_UTF_8);
setMaxPostSize();
String docBase = new File(WorkContext.getCurrent().getPath()).getParent(); String docBase = new File(WorkContext.getCurrent().getPath()).getParent();
//内置的上下文使用工程目录比如webroot //内置的上下文使用工程目录比如webroot
@ -79,6 +80,18 @@ public class FineEmbedServerActivator extends Activator {
context.addServletContainerInitializer(initializer, classes); context.addServletContainerInitializer(initializer, classes);
} }
// tomcat的maxPostSize会影响到post参数获取,默认2M
private void setMaxPostSize() {
if (System.getProperty("tomcat-maxPostSize") != null) {
try {
tomcat.getConnector().setMaxPostSize(Integer.parseInt(System.getProperty("tomcat-maxPostSize")));
} catch (Exception e) {
FineLoggerFactory.getLogger().error("maxPostSize error: " + e.getMessage(), e);
}
}
}
private void stopServerActivator() { private void stopServerActivator() {

62
designer-base/src/test/java/com/fr/design/base/clipboard/ClipboardFilterTest.java

@ -0,0 +1,62 @@
package com.fr.design.base.clipboard;
import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.form.main.ExtraFormClassManager;
import com.fr.plugin.injectable.PluginModule;
import com.fr.stable.fun.mark.Mutable;
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashSet;
import java.util.Set;
@PrepareForTest(PluginModule.class)
@RunWith(PowerMockRunner.class)
public class ClipboardFilterTest {
@Before
public void setUp() throws Exception {
Set<Mutable> providers = new HashSet<>();
providers.add(new TestClipboardHandlerProvider<Object>());
ExtraFormClassManager formClassManager = EasyMock.mock(ExtraFormClassManager.class);
EasyMock.expect(formClassManager.getArray(ClipboardHandlerProvider.XML_TAG))
.andReturn(providers)
.anyTimes();
EasyMock.replay(formClassManager);
PowerMock.mockStatic(PluginModule.class);
EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraForm))
.andReturn(formClassManager)
.anyTimes();
PowerMock.replayAll();
}
@After
public void tearDown() throws Exception {
PowerMock.resetAll();
}
@Test
public void testClipboard() {
ClipboardFilter.cut("cut");
String paste1 = ClipboardFilter.paste("paste");
Assert.assertNull(paste1);
ClipboardFilter.copy("copy");
String paste2 = ClipboardFilter.paste("paste");
Assert.assertNull(paste2);
}
}

75
designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java

@ -0,0 +1,75 @@
package com.fr.design.base.clipboard;
import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.dnd.ArrayListTransferable;
import com.fr.form.main.ExtraFormClassManager;
import com.fr.plugin.injectable.PluginModule;
import com.fr.stable.fun.mark.Mutable;
import com.fr.third.guava.collect.Lists;
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import javax.swing.JPanel;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
@PrepareForTest(PluginModule.class)
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("javax.swing.*")
public class DesignerClipboardTest {
@Before
public void setUp() throws Exception {
Set<Mutable> providers = new HashSet<>();
ExtraFormClassManager formClassManager = EasyMock.mock(ExtraFormClassManager.class);
EasyMock.expect(formClassManager.getArray(ClipboardHandlerProvider.XML_TAG))
.andReturn(providers)
.anyTimes();
EasyMock.replay(formClassManager);
PowerMock.mockStatic(PluginModule.class);
EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraForm))
.andReturn(formClassManager)
.anyTimes();
PowerMock.replayAll();
}
@After
public void tearDown() throws Exception {
PowerMock.resetAll();
}
@Test
public void testClipboard() throws Exception {
JPanel panel = new JPanel();
Clipboard clipboard = DesignerContext.getClipboard(panel);
ArrayList<String> transferData = Lists.newArrayList("test", "test2");
ArrayListTransferable transferable = new ArrayListTransferable(transferData);
clipboard.setContents(transferable, null);
Transferable filterTransferable = clipboard.getContents(null);
DataFlavor[] flavors = transferable.getTransferDataFlavors();
ArrayList<String> transferData2 = (ArrayList<String>) filterTransferable.getTransferData(flavors[0]);
Assert.assertEquals(transferData.get(0), transferData2.get(0));
}
}

29
designer-base/src/test/java/com/fr/design/base/clipboard/TestClipboardHandlerProvider.java

@ -0,0 +1,29 @@
package com.fr.design.base.clipboard;
import com.fr.design.fun.impl.AbstractClipboardHandlerProvider;
/**
* created by Harrison on 2020/05/15
**/
class TestClipboardHandlerProvider<T> extends AbstractClipboardHandlerProvider<T> {
@Override
public T cut(T selection) {
return selection;
}
@Override
public T copy(T selection) {
return selection;
}
@Override
public T paste(T selection) {
return null;
}
@Override
public boolean support(Object selection) {
return true;
}
}

19
designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java

@ -42,7 +42,7 @@ import com.fr.van.chart.drillmap.designer.data.comp.MapDataTree;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JOptionPane; import javax.swing.DefaultComboBoxModel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
@ -51,6 +51,8 @@ import javax.swing.event.PopupMenuListener;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode; import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.util.ArrayList;
import java.util.List;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Component; import java.awt.Component;
@ -61,8 +63,6 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.List;
/** /**
* Created by Mitisky on 16/5/11. * Created by Mitisky on 16/5/11.
@ -280,14 +280,12 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver {
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
String selected = Utils.objectToString(gisLayer.getSelectedItem()); String selected = Utils.objectToString(gisLayer.getSelectedItem());
ZoomLevel zoomSelected = (ZoomLevel) zoomLevel.getSelectedItem();
gisLayer.removeAllItems(); gisLayer.setModel(new DefaultComboBoxModel(MapLayerConfigManager.getLayerItems()));
for (String item : MapLayerConfigManager.getLayerItems()) {
gisLayer.addItem(item);
}
gisLayer.setSelectedItem(selected); gisLayer.setSelectedItem(selected);
zoomLevel.setSelectedItem(zoomSelected);
} }
}); });
@ -346,10 +344,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver {
} else { } else {
levels = ZOOM_LEVELS; levels = ZOOM_LEVELS;
} }
zoomLevel.removeAllItems(); zoomLevel.setModel(new DefaultComboBoxModel(levels));
for (int i = 0; i < levels.length; i++) {
zoomLevel.addItem(levels[i]);
}
} }

13
designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java

@ -1,10 +1,14 @@
package com.fr.design.designer.beans.events; package com.fr.design.designer.beans.events;
import com.fr.design.designer.creator.XComponent; import com.fr.design.designer.creator.XComponent;
import com.fr.design.fun.DesignerEditListenerProvider;
import com.fr.form.main.ExtraFormClassManager;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.plugin.injectable.PluginModule;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Set;
public class CreatorEventListenerTable { public class CreatorEventListenerTable {
@ -28,6 +32,7 @@ public class CreatorEventListenerTable {
} }
private void fireCreatorModified(final DesignerEvent evt) { private void fireCreatorModified(final DesignerEvent evt) {
for (int i = 0; i < listeners.size(); i++) { for (int i = 0; i < listeners.size(); i++) {
final DesignerEditListener listener = listeners.get(i); final DesignerEditListener listener = listeners.get(i);
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@ -37,6 +42,14 @@ public class CreatorEventListenerTable {
} }
}); });
} }
//触发插件的事件
ExtraFormClassManager manager = PluginModule.getAgent(PluginModule.ExtraForm);
Set<DesignerEditListenerProvider> providers = manager.getArray(DesignerEditListenerProvider.XML_TAG);
for (DesignerEditListenerProvider provider : providers) {
provider.fireCreatorModified(evt);
}
} }
public void fireCreatorModified(XComponent creator, int eventID) { public void fireCreatorModified(XComponent creator, int eventID) {

28
designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java

@ -1,12 +1,19 @@
package com.fr.design.designer.beans.models; package com.fr.design.designer.beans.models;
import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.base.clipboard.ClipboardFilter;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.location.Location; import com.fr.design.designer.beans.location.Location;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
@ -19,7 +26,9 @@ import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import java.awt.*; import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
@ -110,18 +119,24 @@ public class SelectionModel {
*/ */
public void cutSelectedCreator2ClipBoard() { public void cutSelectedCreator2ClipBoard() {
if (hasSelectionComponent()) { if (hasSelectionComponent()) {
selection.cut2ClipBoard(clipboard); FormSelection cutSelection = ClipboardFilter.cut(selection);
if (cutSelection != null) {
cutSelection.cut2ClipBoard(clipboard);
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED); designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED);
designer.repaint(); designer.repaint();
} }
} }
}
/** /**
* 复制当前选中的组件到剪切板 * 复制当前选中的组件到剪切板
*/ */
public void copySelectedCreator2ClipBoard() { public void copySelectedCreator2ClipBoard() {
if (!selection.isEmpty()) { if (!selection.isEmpty()) {
selection.copy2ClipBoard(clipboard); FormSelection copySelection = ClipboardFilter.copy(selection);
if (copySelection != null) {
copySelection.copy2ClipBoard(clipboard);
}
} }
} }
@ -131,7 +146,8 @@ public class SelectionModel {
* @return * @return
*/ */
public boolean pasteFromClipBoard() { public boolean pasteFromClipBoard() {
if (!clipboard.isEmpty()) { FormSelection pasteSelection = ClipboardFilter.paste(clipboard);
if (pasteSelection != null && !pasteSelection.isEmpty()) {
if (!hasSelectedPasteSource()) { if (!hasSelectedPasteSource()) {
//未选 //未选
unselectedPaste(); unselectedPaste();
@ -258,11 +274,11 @@ public class SelectionModel {
designer.removeParaComponent(); designer.removeParaComponent();
} }
removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight()); removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight());
FormDesignerUtils.removeWidgetProcessInfo(creator.toData());
creator.deleteRelatedComponent(creator, designer); creator.deleteRelatedComponent(creator, designer);
creator.removeAll(); creator.removeAll();
// 清除被选中的组件 // 清除被选中的组件
selection.reset(); selection.reset();
FormDesignerUtils.removeWidgetProcessInfo(creator.toData());
} }

10
designer-form/src/main/java/com/fr/design/designer/creator/XButton.java

@ -3,8 +3,8 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.base.ScreenResolution;
import com.fr.base.background.GradientBackground; import com.fr.base.background.GradientBackground;
import com.fr.design.form.util.FontTransformUtil;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.widget.editors.ButtonTypeEditor; import com.fr.design.mainframe.widget.editors.ButtonTypeEditor;
@ -148,7 +148,7 @@ public class XButton extends XWidgetCreator {
FreeButton button = (FreeButton) data; FreeButton button = (FreeButton) data;
if (button.getFont() != null) { if (button.getFont() != null) {
contentLabel.setFont(button.getFont().applyResolutionNP( contentLabel.setFont(button.getFont().applyResolutionNP(
ScreenResolution.getScreenResolution())); FontTransformUtil.getDesignerFontResolution()));
contentLabel.setForeground(button.getFont().getForeground()); contentLabel.setForeground(button.getFont().getForeground());
} }
} }
@ -240,7 +240,7 @@ public class XButton extends XWidgetCreator {
editor.add(l,BorderLayout.CENTER); editor.add(l,BorderLayout.CENTER);
if (button.getFont() != null) { if (button.getFont() != null) {
contentLabel.setFont(button.getFont().applyResolutionNP( contentLabel.setFont(button.getFont().applyResolutionNP(
ScreenResolution.getScreenResolution())); FontTransformUtil.getDesignerFontResolution()));
contentLabel.setForeground(button.getFont().getForeground()); contentLabel.setForeground(button.getFont().getForeground());
} }
l.setBounds(0, 0, button.getButtonWidth() == 0 ? this.getWidth() : button.getButtonWidth(), button l.setBounds(0, 0, button.getButtonWidth() == 0 ? this.getWidth() : button.getButtonWidth(), button
@ -257,7 +257,7 @@ public class XButton extends XWidgetCreator {
FreeButton button = (FreeButton) data; FreeButton button = (FreeButton) data;
l.setText(button.getText()); l.setText(button.getText());
if (button.isCustomStyle() && button.getFont() != null) { if (button.isCustomStyle() && button.getFont() != null) {
l.setFont(button.getFont().applyResolutionNP(ScreenResolution.getScreenResolution())); l.setFont(button.getFont().applyResolutionNP(FontTransformUtil.getDesignerFontResolution()));
l.setForeground(button.getFont().getForeground()); l.setForeground(button.getFont().getForeground());
} }
@ -303,7 +303,7 @@ public class XButton extends XWidgetCreator {
checkButonType(); checkButonType();
if (button.getFont() != null) { if (button.getFont() != null) {
contentLabel.setFont(button.getFont().applyResolutionNP( contentLabel.setFont(button.getFont().applyResolutionNP(
ScreenResolution.getScreenResolution())); FontTransformUtil.getDesignerFontResolution()));
contentLabel.setForeground(button.getFont().getForeground()); contentLabel.setForeground(button.getFont().getForeground());
} }

5
designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java

@ -4,9 +4,9 @@
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.ScreenResolution;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.form.util.FontTransformUtil;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.widget.editors.FontEditor; import com.fr.design.mainframe.widget.editors.FontEditor;
@ -98,7 +98,8 @@ public class XLabel extends XWidgetCreator {
.toString(), Style.getInstance(label.getFont()).deriveHorizontalAlignment(label.getTextalign()) .toString(), Style.getInstance(label.getFont()).deriveHorizontalAlignment(label.getTextalign())
.deriveVerticalAlignment(label.isVerticalCenter() ? SwingConstants.CENTER : SwingConstants.TOP) .deriveVerticalAlignment(label.isVerticalCenter() ? SwingConstants.CENTER : SwingConstants.TOP)
.deriveTextStyle(label.isWrap() ? Style.TEXTSTYLE_WRAPTEXT : Style.TEXTSTYLE_SINGLELINE), .deriveTextStyle(label.isWrap() ? Style.TEXTSTYLE_WRAPTEXT : Style.TEXTSTYLE_SINGLELINE),
ScreenResolution.getScreenResolution()); FontTransformUtil.getDesignerFontResolution());
} }
} }

4
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) { private void initPercent(WAbsoluteLayout widget) {
Toolkit toolkit = Toolkit.getDefaultToolkit(); Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize(); Dimension scrnsize = toolkit.getScreenSize();
double screenValue = FRScreen.getByDimension(scrnsize).getValue(); double screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue();
if (!AssistUtils.equals(screenValue, FormArea.DEFAULT_SLIDER)) { if (!AssistUtils.equals(screenValue, FormArea.DEFAULT_SLIDER)) {
this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER);
} }
@ -247,7 +247,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
*/ */
@Override @Override
public void updateChildBound(int minHeight) { 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)) { if (toData().getCompState() == 0 && !AssistUtils.equals(containerPercent, prevContainerPercent)) {
for (int i = 0; i < this.getComponentCount(); i++) { for (int i = 0; i < this.getComponentCount(); i++) {
XCreator creator = getXCreator(i); XCreator creator = getXCreator(i);

2
designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java

@ -72,7 +72,7 @@ public class XWFitLayout extends XLayoutContainer {
private void initPercent(){ private void initPercent(){
Toolkit toolkit = Toolkit.getDefaultToolkit(); Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize(); Dimension scrnsize = toolkit.getScreenSize();
double screenValue = FRScreen.getByDimension(scrnsize).getValue(); double screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue();
if (!AssistUtils.equals(FormArea.DEFAULT_SLIDER, screenValue)) { if (!AssistUtils.equals(FormArea.DEFAULT_SLIDER, screenValue)) {
this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER);
} }

46
designer-form/src/main/java/com/fr/design/form/util/FontTransformUtil.java

@ -0,0 +1,46 @@
package com.fr.design.form.util;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.FormAdaptiveConfigUIProcessor;
import com.fr.stable.Constants;
import com.fr.stable.unit.PT;
/**
* Created by kerry on 2020-04-16
*/
public class FontTransformUtil {
/**
* 获取设计器字体显示dpi
* @return dpi
*/
public static int getDesignerFontResolution() {
int dpi = Constants.FR_PAINT_RESOLUTION;
FormAdaptiveConfigUIProcessor adaptiveConfigUI = ExtraDesignClassManager.getInstance().getSingle(FormAdaptiveConfigUIProcessor.MARK_STRING);
if (adaptiveConfigUI != null) {
dpi = adaptiveConfigUI.fontResolution();
}
return dpi;
}
/**
* pt值转px
* @param value pt值
* @return px值
*/
public static double pt2px(double value) {
return PT.pt2pix(value, getDesignerFontResolution());
}
/**
* px值转pt
* @param value px值
* @return pt值
*/
public static double px2pt(double value) {
return value * (double) Constants.DEFAULT_FONT_PAINT_RESOLUTION / (double) getDesignerFontResolution();
}
}

22
designer-form/src/main/java/com/fr/design/fun/DesignerEditListenerProvider.java

@ -0,0 +1,22 @@
package com.fr.design.fun;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.stable.fun.mark.Mutable;
/**
* created by Harrison on 2020/05/14
**/
public interface DesignerEditListenerProvider extends Mutable {
String XML_TAG = "DesignerEditListenerProvider";
int CURRENT_LEVEL = 1;
/**
* 触发设计器事件
*
* @param evt 事件
*/
void fireCreatorModified(DesignerEvent evt);
}

17
designer-form/src/main/java/com/fr/design/fun/impl/AbstractDesignerEditListenerProvider.java

@ -0,0 +1,17 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.DesignerEditListenerProvider;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
/**
* created by Harrison on 2020/05/14
**/
@API(level = DesignerEditListenerProvider.CURRENT_LEVEL)
public abstract class AbstractDesignerEditListenerProvider extends AbstractProvider implements DesignerEditListenerProvider {
@Override
public int currentAPILevel() {
return DesignerEditListenerProvider.CURRENT_LEVEL;
}
}

2
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); // controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_CLOSE_ICON_PATH);
controlButton.setVisible(false); controlButton.setVisible(false);
helpDialog = new WidgetHelpDialog(DesignerContext.getDesignerFrame(), helpMsg); 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; int offsetX = 0;
if (screenValue < FormArea.DEFAULT_SLIDER) { if (screenValue < FormArea.DEFAULT_SLIDER) {
offsetX = (int) ((1 - screenValue / FormArea.DEFAULT_SLIDER) offsetX = (int) ((1 - screenValue / FormArea.DEFAULT_SLIDER)

2
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() { private void initCalculateSize() {
Toolkit toolkit = Toolkit.getDefaultToolkit(); Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension scrnsize = toolkit.getScreenSize(); Dimension scrnsize = toolkit.getScreenSize();
this.screenValue = FRScreen.getByDimension(scrnsize).getValue(); this.screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue();
XLayoutContainer root = FormArea.this.designer.getRootComponent(); XLayoutContainer root = FormArea.this.designer.getRootComponent();
// 7.1.1不放缩放滑块,但表单大小仍按屏幕分辨率调整 // 7.1.1不放缩放滑块,但表单大小仍按屏幕分辨率调整
// slidePane.populateBean(screenValue); // slidePane.populateBean(screenValue);

36
designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java

@ -1,10 +1,17 @@
package com.fr.design.mainframe.template.info; 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.ChartEditor;
import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.Widget; 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.WAbsoluteLayout;
import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WScaleLayout;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
/** /**
@ -20,8 +27,19 @@ public abstract class ComponentOperate implements TemplateOperate {
private Widget widget; private Widget widget;
public ComponentOperate(Widget widget) { public ComponentOperate(Widget widget) {
this.widget = widget; Widget innerWidget = widget;
if (innerWidget.acceptType(WScaleLayout.class)) {
Widget crBoundsWidget = ((WScaleLayout) innerWidget).getBoundsWidget();
innerWidget = ((CRBoundsWidget) crBoundsWidget).getWidget();
} else if (innerWidget.acceptType(WTitleLayout.class)) {
CRBoundsWidget crBoundsWidget = ((WTitleLayout) innerWidget).getBodyBoundsWidget();
innerWidget = crBoundsWidget.getWidget();
} else if (innerWidget.acceptType(WCardMainBorderLayout.class)){
innerWidget = ((WCardMainBorderLayout) widget).getCardPart();
} }
this.widget = innerWidget;
}
@Override @Override
public JSONObject toJSONObject() { public JSONObject toJSONObject() {
@ -50,6 +68,11 @@ public abstract class ComponentOperate implements TemplateOperate {
Widget { Widget {
@Override @Override
protected boolean acceptType(Widget widget) { protected boolean acceptType(Widget widget) {
for (WidgetOption widgetOption : WidgetOption.getFormWidgetIntance()) {
if (ComparatorUtils.equals(widget.getClass(), widgetOption.widgetClass())) {
return true;
}
}
return false; return false;
} }
}, },
@ -62,7 +85,7 @@ public abstract class ComponentOperate implements TemplateOperate {
Absolute { Absolute {
@Override @Override
protected boolean acceptType(Widget widget) { protected boolean acceptType(Widget widget) {
return widget.acceptType(WAbsoluteLayout.class); return widget.acceptType(WAbsoluteLayout.class) && !widget.acceptType(WAbsoluteBodyLayout.class);
} }
}; };
@ -76,5 +99,14 @@ public abstract class ComponentOperate implements TemplateOperate {
} }
return Widget; return Widget;
} }
public static boolean supportComponent(Widget widget) {
for (ComponentType componentType : values()) {
if (componentType.acceptType(widget)) {
return true;
}
}
return false;
}
} }
} }

24
designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.template.info; package com.fr.design.mainframe.template.info;
import com.fr.base.iofile.attr.ExtendSharableAttrMark; import com.fr.base.iofile.attr.ExtendSharableAttrMark;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.form.FormElementCaseProvider; import com.fr.form.FormElementCaseProvider;
import com.fr.form.main.Form; import com.fr.form.main.Form;
@ -21,6 +22,7 @@ import com.fr.report.cell.DefaultTemplateCellElement;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -61,12 +63,21 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
// 获取模板控件数 // 获取模板控件数
public int getWidgetCount() { public int getWidgetCount() {
int widgetCount = 0; final AtomicInteger widgetCount = new AtomicInteger();
for (int i = 0; i < template.getContainer().getWidgetCount(); i++) { Form.traversalWidget(this.template.getContainer(), new WidgetGather() {
WLayout wl = (WLayout) template.getContainer().getWidget(i); @Override
widgetCount += wl.getWidgetCount(); public void dealWith(Widget widget) {
if (ComponentOperate.ComponentType.supportComponent(widget)) {
widgetCount.incrementAndGet();
} }
return widgetCount; }
@Override
public boolean dealWithAllCards() {
return true;
}
}, null);
return widgetCount.get();
} }
@Override @Override
@ -215,6 +226,9 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
private void addComponentRemoveInfo(JSONObject jsonObject) { private void addComponentRemoveInfo(JSONObject jsonObject) {
String componentID = jsonObject.getString("componentID"); String componentID = jsonObject.getString("componentID");
if (componentID == null){
return;
}
JSONObject info = componentProcessInfoMap.get(componentID); JSONObject info = componentProcessInfoMap.get(componentID);
if (info == null) { if (info == null) {
info = jsonObject; info = jsonObject;

102
designer-form/src/test/java/com/fr/design/designer/beans/models/SelectionModelTest.java

@ -0,0 +1,102 @@
package com.fr.design.designer.beans.models;
import com.fr.design.designer.beans.events.CreatorEventListenerTable;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.fun.ClipboardHandlerProvider;
import com.fr.design.fun.impl.AbstractClipboardHandlerProvider;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.main.ExtraFormClassManager;
import com.fr.plugin.injectable.PluginModule;
import com.fr.stable.fun.mark.Mutable;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import java.util.HashSet;
import java.util.Set;
@PrepareForTest(PluginModule.class)
@SuppressStaticInitializationFor({"com.fr.design.mainframe.FormDesigner"})
@PowerMockIgnore("javax.swing.*")
@RunWith(PowerMockRunner.class)
public class SelectionModelTest {
@Before
public void setUp() throws Exception {
AbstractClipboardHandlerProvider provider = EasyMock.mock(AbstractClipboardHandlerProvider.class);
EasyMock.expect(provider.cut(EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
return null;
}
}).anyTimes();
EasyMock.expect(provider.copy(EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
return EasyMock.getCurrentArguments()[0];
}
}).anyTimes();
EasyMock.expect(provider.support(EasyMock.anyObject())).andReturn(true).anyTimes();
EasyMock.expect(provider.paste(EasyMock.anyObject())).andReturn(null).anyTimes();
EasyMock.replay(provider);
Set<Mutable> providers = new HashSet<>();
providers.add(provider);
ExtraFormClassManager formClassManager = EasyMock.mock(ExtraFormClassManager.class);
EasyMock.expect(formClassManager.getArray(ClipboardHandlerProvider.XML_TAG))
.andReturn(providers)
.anyTimes();
EasyMock.expect(formClassManager.getArray("DesignerEditListenerProvider"))
.andReturn(new HashSet<Mutable>())
.anyTimes();
EasyMock.replay(formClassManager);
PowerMock.mockStatic(PluginModule.class);
EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraForm))
.andReturn(formClassManager)
.anyTimes();
PowerMock.replayAll();
}
@After
public void tearDown() throws Exception {
PowerMock.resetAll();
}
@Test
public void testPaste() {
FormDesigner formDesigner = EasyMock.partialMockBuilder(FormDesigner.class).createMock();
XCreator xCreator = EasyMock.mock(XCreator.class);
EasyMock.expect(xCreator.acceptType(EasyMock.anyObject(Class[].class))).andReturn(true).anyTimes();
CreatorEventListenerTable table = new CreatorEventListenerTable();
Whitebox.setInternalState(formDesigner, "edit", table);
EasyMock.replay(formDesigner, xCreator);
SelectionModel model = new SelectionModel(formDesigner);
model.cutSelectedCreator2ClipBoard();
boolean paste1 = model.pasteFromClipBoard();
Assert.assertFalse(paste1);
model.setSelectedCreator(xCreator);
model.copySelectedCreator2ClipBoard();
boolean paste2 = model.pasteFromClipBoard();
Assert.assertFalse(paste2);
}
}

68
designer-form/src/test/java/com/fr/design/form/util/FontTransformUtilTest.java

@ -0,0 +1,68 @@
package com.fr.design.form.util;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.FormAdaptiveConfigUIProcessor;
import com.fr.stable.Constants;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
/**
* Created by kerry on 2020-05-14
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(ExtraDesignClassManager.class)
public class FontTransformUtilTest {
@Test
public void testGetDesignerFontResolution() {
mockEnvironment(Constants.DEFAULT_FONT_PAINT_RESOLUTION);
Assert.assertEquals(Constants.DEFAULT_FONT_PAINT_RESOLUTION, FontTransformUtil.getDesignerFontResolution());
mockEnvironment(Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION);
Assert.assertEquals(Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION, FontTransformUtil.getDesignerFontResolution());
}
@Test
public void testPt2px() {
mockEnvironment(Constants.DEFAULT_FONT_PAINT_RESOLUTION);
Assert.assertEquals(12, (int) FontTransformUtil.pt2px(12));
mockEnvironment(Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION);
Assert.assertEquals(16, (int) FontTransformUtil.pt2px(12));
}
@Test
public void testPx2pt() {
mockEnvironment(Constants.DEFAULT_FONT_PAINT_RESOLUTION);
Assert.assertEquals(12, (int) FontTransformUtil.px2pt(12));
mockEnvironment(Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION);
Assert.assertEquals(9, (int) FontTransformUtil.px2pt(12));
}
private void mockEnvironment(int dpi) {
ExtraDesignClassManager mockDesignManager = EasyMock.mock(ExtraDesignClassManager.class);
EasyMock.expect(mockDesignManager.getSingle(FormAdaptiveConfigUIProcessor.MARK_STRING))
.andReturn(mockProcessor(dpi)).anyTimes();
EasyMock.replay(mockDesignManager);
PowerMock.mockStatic(ExtraDesignClassManager.class);
EasyMock.expect(ExtraDesignClassManager.getInstance()).andReturn(mockDesignManager).once();
PowerMock.replayAll(ExtraDesignClassManager.class);
}
private FormAdaptiveConfigUIProcessor mockProcessor(int dpi) {
FormAdaptiveConfigUIProcessor processor = EasyMock.mock(FormAdaptiveConfigUIProcessor.class);
EasyMock.expect(processor.fontResolution()).andReturn(dpi).once();
EasyMock.replay(processor);
return processor;
}
}

52
designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java

@ -1,19 +1,59 @@
package com.fr.design.mainframe.template.info; 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.ChartEditor;
import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.FreeButton; import com.fr.form.ui.FreeButton;
import com.fr.form.ui.TextEditor;
import com.fr.form.ui.Widget; 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.WAbsoluteLayout;
import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WScaleLayout;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.awt.Rectangle;
/** /**
* Created by kerry on 2020-05-08 * Created by kerry on 2020-05-08
*/ */
public class ComponentCreateOperateTest { public class ComponentCreateOperateTest {
@Test
public void testConstructor() {
ElementCaseEditor caseEditor = new ElementCaseEditor();
caseEditor.setWidgetName("report0");
caseEditor.setWidgetID("xxxx0");
WTitleLayout wTitleLayout = new WTitleLayout();
wTitleLayout.addBody(caseEditor, new Rectangle());
ComponentOperate componentOperate0 = new ComponentCreateOperate(caseEditor);
ComponentOperate componentOperate1 = new ComponentCreateOperate(wTitleLayout);
ComparatorUtils.equals(componentOperate0.toJSONObject(), componentOperate1.toJSONObject());
WScaleLayout scaleLayout = new WScaleLayout();
TextEditor textEditor = new TextEditor();
scaleLayout.addWidget(new CRBoundsWidget(textEditor, new Rectangle()));
ComponentOperate componentOperate3 = new ComponentCreateOperate(scaleLayout);
ComponentOperate componentOperate4 = new ComponentCreateOperate(textEditor);
ComparatorUtils.equals(componentOperate3.toJSONObject(), componentOperate4.toJSONObject());
WCardMainBorderLayout wCardMainBorderLayout = new WCardMainBorderLayout();
WCardLayout wCardLayout = new WCardLayout();
wCardMainBorderLayout.addCenter(wCardLayout);
ComponentOperate componentOperate5 = new ComponentCreateOperate(wCardMainBorderLayout);
ComponentOperate componentOperate6 = new ComponentCreateOperate(wCardLayout);
ComparatorUtils.equals(componentOperate5.toJSONObject(), componentOperate6.toJSONObject());
}
@Test @Test
public void testToJSONObject() { public void testToJSONObject() {
Widget button = new FreeButton(); Widget button = new FreeButton();
@ -35,4 +75,16 @@ public class ComponentCreateOperateTest {
Assert.assertEquals(ComponentOperate.ComponentType.Absolute, ComponentOperate.ComponentType.parseType(new WAbsoluteLayout())); Assert.assertEquals(ComponentOperate.ComponentType.Absolute, ComponentOperate.ComponentType.parseType(new WAbsoluteLayout()));
Assert.assertEquals(ComponentOperate.ComponentType.TabLayout, ComponentOperate.ComponentType.parseType(new WCardLayout())); 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()));
}
} }

30
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.ChartEditor;
import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.FreeButton; 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.WAbsoluteLayout;
import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WCardLayout;
@ -142,8 +143,37 @@ public class JFormProcessInfoTest {
JSONArray ja = jFormProcessInfo.getComponentsInfo(); JSONArray ja = jFormProcessInfo.getComponentsInfo();
Assert.assertEquals(2, ja.size()); Assert.assertEquals(2, ja.size());
Reflect.on(jFormProcessInfo).call("addComponentCreateInfo", new ComponentCreateOperate(button1).toJSONObject());
FreeButton button3 = new FreeButton();
Reflect.on(jFormProcessInfo).call("addComponentRemoveInfo", new ComponentDeleteOperate(button3).toJSONObject());
Assert.assertEquals(1, jFormProcessInfo.getComponentsInfo().size());
ja = jFormProcessInfo.getComponentsInfo(); ja = jFormProcessInfo.getComponentsInfo();
Assert.assertEquals(0, ja.size()); 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());
}
} }

14
designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java

@ -8,6 +8,7 @@ import com.fr.base.BaseUtils;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.form.util.FontTransformUtil;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -21,7 +22,6 @@ import com.fr.design.style.color.UIToolbarColorButton;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.report.cell.cellattr.core.RichTextConverter; import com.fr.report.cell.cellattr.core.RichTextConverter;
import com.fr.stable.Constants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -494,20 +494,12 @@ public class RichTextToolBar extends BasicPane{
//pt转为px =*4/3 //pt转为px =*4/3
private int scaleUp(int fontSize) { private int scaleUp(int fontSize) {
return scale(fontSize, true); return (int) FontTransformUtil.pt2px(fontSize);
} }
//px转pt = *3/4 //px转pt = *3/4
private int scaleDown(int fontSize) { private int scaleDown(int fontSize) {
return scale(fontSize, false); return (int) FontTransformUtil.px2pt(fontSize);
}
private int scale(int fontSize, boolean isUp){
double dpi96 = Constants.FR_PAINT_RESOLUTION;
double dpi72 = Constants.DEFAULT_FONT_PAINT_RESOLUTION;
double scale = isUp ? (dpi96 / dpi72) : (dpi72 / dpi96);
return roundUp(fontSize * scale);
} }
private DocumentListener inputListener = new DocumentListener() { private DocumentListener inputListener = new DocumentListener() {

10
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java

@ -918,9 +918,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
actionMap.put("paste", new AbstractAction() { actionMap.put("paste", new AbstractAction() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
if (paste()) { if (paste()) {
QuickEditorRegion.getInstance().populate(getCurrentEditor()); afterPasteAction();
fireTargetModified();
QuickEditorRegion.getInstance().populate(getCurrentEditor());
} }
} }
}); });
@ -942,6 +940,12 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
}); });
} }
protected void afterPasteAction() {
QuickEditorRegion.getInstance().populate(getCurrentEditor());
fireTargetModified();
QuickEditorRegion.getInstance().populate(getCurrentEditor());
}
/** /**
* 是否列表头可见 * 是否列表头可见
* *

7
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java

@ -38,6 +38,7 @@ import com.fr.stable.ArrayUtils;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
/** /**
* 类说明: 设计面板中最上方的"插入" "单元格"下拉列表Menu模块. * 类说明: 设计面板中最上方的"插入" "单元格"下拉列表Menu模块.
* *
@ -113,6 +114,12 @@ public class ElementCasePaneDelegate extends ElementCasePane<WorkSheet> {
} }
} }
@Override
protected void afterPasteAction() {
refreshPropertyPanes();
repaint();
}
@Override @Override
protected boolean supportRepeatedHeaderFooter() { protected boolean supportRepeatedHeaderFooter() {
return true; return true;

15
designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java

@ -1,8 +1,5 @@
package com.fr.design.mainframe.form; package com.fr.design.mainframe.form;
import javax.swing.JComponent;
import javax.swing.JPanel;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
@ -11,7 +8,6 @@ import com.fr.design.actions.form.FormECColumnsAction;
import com.fr.design.actions.form.FormECFrozenAction; import com.fr.design.actions.form.FormECFrozenAction;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.mainframe.*; import com.fr.design.mainframe.*;
import com.fr.design.mainframe.cell.QuickEditorRegion; import com.fr.design.mainframe.cell.QuickEditorRegion;
@ -22,13 +18,14 @@ import com.fr.design.menu.ToolBarDef;
import com.fr.design.present.ConditionAttributesGroupPane; import com.fr.design.present.ConditionAttributesGroupPane;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.grid.Grid; import com.fr.grid.Grid;
import com.fr.js.NameJavaScriptGroup;
import com.fr.page.ReportSettingsProvider; import com.fr.page.ReportSettingsProvider;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.report.worksheet.FormElementCase; import com.fr.report.worksheet.FormElementCase;
import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionEvent;
import com.fr.design.selection.SelectionListener; import com.fr.design.selection.SelectionListener;
import javax.swing.JComponent;
import javax.swing.JPanel;
/** /**
*/ */
public class FormElementCasePaneDelegate extends ElementCasePane<FormElementCase>{ public class FormElementCasePaneDelegate extends ElementCasePane<FormElementCase>{
@ -72,6 +69,12 @@ public class FormElementCasePaneDelegate extends ElementCasePane<FormElementCase
EastRegionContainerPane.getInstance().updateCellElementState(isSelectedOneCell()); EastRegionContainerPane.getInstance().updateCellElementState(isSelectedOneCell());
} }
@Override
protected void afterPasteAction() {
refreshPropertyPanes();
repaint();
}
@Override @Override
protected boolean supportRepeatedHeaderFooter() { protected boolean supportRepeatedHeaderFooter() {
return true; return true;

3
designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java

@ -101,6 +101,9 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo<WorkBook> {
for (int i = 0; i < columnLength; i++) { for (int i = 0; i < columnLength; i++) {
for (int j = 0; j < rowLength; j++) { for (int j = 0; j < rowLength; j++) {
TemplateCellElement templateCellElement = templateElementCase.getTemplateCellElement(i, j); TemplateCellElement templateCellElement = templateElementCase.getTemplateCellElement(i, j);
if (templateCellElement == null) {
continue;
}
Object value = templateCellElement.getValue(); Object value = templateCellElement.getValue();
if (isTestCell(value, templateCellElement.getStyle())) { if (isTestCell(value, templateCellElement.getStyle())) {
return true; return true;

3
designer-realize/src/main/java/com/fr/design/report/RichTextPane.java

@ -1,6 +1,7 @@
package com.fr.design.report; package com.fr.design.report;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.base.FRContext;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.cell.editor.RichTextToolBar; import com.fr.design.cell.editor.RichTextToolBar;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
@ -36,7 +37,7 @@ public class RichTextPane extends BasicPane {
//12号字体有个奇怪的bug, 字体下部分渲染会截断一部分, 换其他字体没问题, 字体改大小也没问题. //12号字体有个奇怪的bug, 字体下部分渲染会截断一部分, 换其他字体没问题, 字体改大小也没问题.
//直接弄个jtexarea放到jframe里也有同样问题, 不知道是字体渲染bug还是jdk问题 //直接弄个jtexarea放到jframe里也有同样问题, 不知道是字体渲染bug还是jdk问题
public static final FRFont DEFAUL_FONT = FRFont.getInstance().applySize(13); public static final FRFont DEFAUL_FONT = FRContext.getDefaultValues().getFRFont().applySize(13);
private RichTextEditingPane textPane; private RichTextEditingPane textPane;
//用于populate时动态更新按钮 //用于populate时动态更新按钮

5
designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java

@ -49,10 +49,7 @@ public class LifecycleFatalErrorHandler {
public void handle(FineLifecycleFatalError fatal) { public void handle(FineLifecycleFatalError fatal) {
SplashContext.getInstance().hide(); SplashContext.getInstance().hide();
ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.STOP.getValue()));
if (eventPipe != null) {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
}
map.get(fatal.getErrorType()).handle(fatal); map.get(fatal.getErrorType()).handle(fatal);
} }

Loading…
Cancel
Save