Browse Source

Merge pull request #1124 in DESIGN/design from final/10.0 to bugfix/10.0

* commit '2edd2ae67002b8754ff9a6709bcb1846e9769405': (21 commits)
  换一个扩展性更好的方式
  rt
  REPORT-19557 ToolbarItemProvider接口需要支持表单报表块
  取消屏蔽
  屏蔽回传代码
  补充日志
  fix 调试输出
  update
  REPORT-21871 批量添加单元格组 合并场景
  REPORT-21584 设置参数界面的设计宽度到100,所有控件还是可以正常显示
  update
  REPORT-20769  模版数据集数据库模糊查询交互产品改进 && REPORT-14560 同步到10.0
  REPORT-19945 设计器启动信息收集
  REPORT-19945 设计器启动信息收集
  客户端携带鉴权
  回传
  设计器回传
  隐私策略调整
  云端运维固化数据存储
  无
  ...
bugfix/10.0
neil 5 years ago
parent
commit
6d6e70d3a2
  1. 33
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  2. 31
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  3. 7
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java
  4. 26
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  5. 12
      designer-base/src/main/java/com/fr/design/fun/ToolbarItemProvider.java
  6. 12
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractToolbarItem.java
  7. 70
      designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java
  8. 11
      designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleElementCaseToolBarEditor.java
  9. 20
      designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java
  10. 203
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java
  11. 92
      designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java
  12. 18
      designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollectConstants.java
  13. 97
      designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java
  14. 20
      designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java
  15. 2
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java
  16. 11
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

33
designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java

@ -23,6 +23,7 @@ import com.fr.plugin.AbstractExtraClassManager;
import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.injectable.PluginSingleInjection; import com.fr.plugin.injectable.PluginSingleInjection;
import com.fr.plugin.solution.closeable.CloseableContainedSet; import com.fr.plugin.solution.closeable.CloseableContainedSet;
import com.fr.stable.Filter;
import com.fr.stable.plugin.ExtraDesignClassManagerProvider; import com.fr.stable.plugin.ExtraDesignClassManagerProvider;
import java.util.ArrayList; import java.util.ArrayList;
@ -113,26 +114,39 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
return result.toArray(new WidgetOption[result.size()]); return result.toArray(new WidgetOption[result.size()]);
} }
public WidgetOption[] getWebWidgetOptions() { public WidgetOption[] getWebWidgetOptions() {
return getWebWidgetOptions(new Filter<ToolbarItemProvider>() {
@Override
public boolean accept(ToolbarItemProvider toolbarItemProvider) {
return true;
}
});
}
public WidgetOption[] getWebWidgetOptions(Filter<ToolbarItemProvider> filter) {
Set<ToolbarItemProvider> set = getArray(ToolbarItemProvider.XML_TAG); Set<ToolbarItemProvider> set = getArray(ToolbarItemProvider.XML_TAG);
if (set.isEmpty()) { return getWebWidgetOptions(set, filter);
}
public WidgetOption[] getWebWidgetOptions(Set<ToolbarItemProvider> set, Filter<ToolbarItemProvider> filter) {
if (set == null || set.isEmpty()) {
return new WidgetOption[0]; return new WidgetOption[0];
} }
List<WidgetOption> list = new ArrayList<>(); List<WidgetOption> list = new ArrayList<>();
for (ToolbarItemProvider provider : set) { for (ToolbarItemProvider provider : set) {
WidgetOption option = WidgetOptionFactory.createByWidgetClass( if (filter != null && filter.accept(provider)) {
provider.nameForWidget(), WidgetOption option = WidgetOptionFactory.createByWidgetClass(
IOUtils.readIcon(provider.iconPathForWidget()), provider.nameForWidget(),
provider.classForWidget() IOUtils.readIcon(provider.iconPathForWidget()),
); provider.classForWidget()
list.add(option); );
list.add(option);
}
} }
return list.toArray(new WidgetOption[list.size()]); return list.toArray(new WidgetOption[list.size()]);
} }
public Map<Class<? extends Widget>, Class<?>> getFormWidgetOptionsMap() { public Map<Class<? extends Widget>, Class<?>> getFormWidgetOptionsMap() {
Set<FormWidgetOptionProvider> set = getArray(FormWidgetOptionProvider.XML_TAG); Set<FormWidgetOptionProvider> set = getArray(FormWidgetOptionProvider.XML_TAG);
Map<Class<? extends Widget>, Class<?>> map = new HashMap<>(); Map<Class<? extends Widget>, Class<?>> map = new HashMap<>();
@ -170,7 +184,6 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
} }
public WidgetOption[] getCellWidgetOptions() { public WidgetOption[] getCellWidgetOptions() {
Set<CellWidgetOptionProvider> set = getArray(CellWidgetOptionProvider.XML_TAG); Set<CellWidgetOptionProvider> set = getArray(CellWidgetOptionProvider.XML_TAG);
if (set.isEmpty()) { if (set.isEmpty()) {

31
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -3,6 +3,7 @@ package com.fr.design.actions.file;
import com.fr.config.Configuration; import com.fr.config.Configuration;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
@ -28,12 +29,14 @@ import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.update.push.DesignerPushUpdateManager; import com.fr.design.update.push.DesignerPushUpdateManager;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.log.Log4jConfig; import com.fr.general.log.Log4jConfig;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.Level;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.Worker;
@ -48,6 +51,8 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
import java.awt.Window; import java.awt.Window;
@ -58,6 +63,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.io.File; import java.io.File;
import java.net.URI;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -105,6 +111,7 @@ public class PreferencePane extends BasicPane {
private static final String DISPLAY_EQUALS = "+"; private static final String DISPLAY_EQUALS = "+";
private static final String MINUS = "MINUS"; private static final String MINUS = "MINUS";
private static final String DISPLAY_MINUS = "-"; private static final String DISPLAY_MINUS = "-";
private static final String PRIVACY_POLICY = "design.privacy";
private static final Level[] LOG = {Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG}; private static final Level[] LOG = {Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG};
@ -147,6 +154,7 @@ public class PreferencePane extends BasicPane {
private UICheckBox useIntervalCheckBox; private UICheckBox useIntervalCheckBox;
private IntegerEditor saveIntervalEditor; private IntegerEditor saveIntervalEditor;
private UILabel remindVcsLabel; private UILabel remindVcsLabel;
private UILabel linkLabel;
@ -205,8 +213,27 @@ public class PreferencePane extends BasicPane {
JPanel improvePane = FRGUIPaneFactory.createVerticalTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Product_Improve")); JPanel improvePane = FRGUIPaneFactory.createVerticalTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Product_Improve"));
joinProductImproveCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Join_Product_Improve")); joinProductImproveCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Join_Product_Improve"));
improvePane.add(joinProductImproveCheckBox); linkLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Privacy_Policy"));
linkLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
linkLabel.setForeground(UIConstants.NORMAL_BLUE);
linkLabel.addMouseListener(new MouseAdapter(){
@Override
public void mouseClicked(MouseEvent e) {
try {
Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind(PRIVACY_POLICY)));
} catch (Exception e1) {
FineLoggerFactory.getLogger().error(e1.getMessage(), e1);
}
}
});
double p = TableLayout.PREFERRED;
double rowSize[] = {p};
double columnSize[] = {p, p};
Component[][] components = {
{joinProductImproveCheckBox, linkLabel},
};
JPanel choosePane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
improvePane.add(choosePane);
if (DesignerPushUpdateManager.getInstance().isAutoPushUpdateSupported()) { if (DesignerPushUpdateManager.getInstance().isAutoPushUpdateSupported()) {
autoPushUpdateCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Automatic_Push_Update")); autoPushUpdateCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Automatic_Push_Update"));
improvePane.add(autoPushUpdateCheckBox); improvePane.add(autoPushUpdateCheckBox);

7
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java

@ -35,7 +35,7 @@ public class ConnectionTableProcedurePane extends BasicPane {
private ConnectionComboBoxPanel connectionComboBox; private ConnectionComboBoxPanel connectionComboBox;
private UICheckBox tableCheckBox; private UICheckBox tableCheckBox;
private UICheckBox viewCheckBox; private UICheckBox viewCheckBox;
private UITextField searchField; protected UITextField searchField;
private TableViewList tableViewList; private TableViewList tableViewList;
private java.util.List<DoubleClickSelectedNodeOnTreeListener> listeners = new java.util.ArrayList<DoubleClickSelectedNodeOnTreeListener>(); private java.util.List<DoubleClickSelectedNodeOnTreeListener> listeners = new java.util.ArrayList<DoubleClickSelectedNodeOnTreeListener>();
@ -90,12 +90,17 @@ public class ConnectionTableProcedurePane extends BasicPane {
this.add(tableViewListPane, BorderLayout.CENTER); this.add(tableViewListPane, BorderLayout.CENTER);
this.add(filterPane, BorderLayout.SOUTH); this.add(filterPane, BorderLayout.SOUTH);
this.setPreferredSize(new Dimension(WIDTH, getPreferredSize().height)); this.setPreferredSize(new Dimension(WIDTH, getPreferredSize().height));
addKeyMonitor();
} }
protected void filter(Connection connection, String conName, List<String> nameList) { protected void filter(Connection connection, String conName, List<String> nameList) {
connection.addConnection(nameList, conName, new Class[]{AbstractDatabaseConnection.class}); connection.addConnection(nameList, conName, new Class[]{AbstractDatabaseConnection.class});
} }
protected void addKeyMonitor() {
}
protected JPanel createCheckBoxgroupPane() { protected JPanel createCheckBoxgroupPane() {
JPanel checkBoxgroupPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2); JPanel checkBoxgroupPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2);
JPanel first = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel first = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();

26
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java

@ -57,6 +57,8 @@ import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.FocusListener; import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -95,6 +97,30 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class}); connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class});
} }
@Override
protected void addKeyMonitor() {
searchField.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
e.setKeyCode(KeyEvent.VK_UP);
DBTableDataPane.this.connectionTableProcedurePane.requestFocus();
}
}
@Override
public void keyReleased(KeyEvent e) {
}
});
}
}; };
connectionTableProcedurePane.addDoubleClickListener(new DoubleClickSelectedNodeOnTreeListener() { connectionTableProcedurePane.addDoubleClickListener(new DoubleClickSelectedNodeOnTreeListener() {

12
designer-base/src/main/java/com/fr/design/fun/ToolbarItemProvider.java

@ -1,6 +1,8 @@
package com.fr.design.fun; package com.fr.design.fun;
import com.fr.design.mainframe.JTemplate;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.stable.Filter;
import com.fr.stable.fun.mark.Mutable; import com.fr.stable.fun.mark.Mutable;
/** /**
@ -8,7 +10,7 @@ import com.fr.stable.fun.mark.Mutable;
* @since : 8.0 * @since : 8.0
* 自定义web工具栏菜单 * 自定义web工具栏菜单
*/ */
public interface ToolbarItemProvider extends Mutable { public interface ToolbarItemProvider extends Mutable, Filter<JTemplate> {
String XML_TAG = "ToolbarItemProvider"; String XML_TAG = "ToolbarItemProvider";
@ -36,4 +38,12 @@ public interface ToolbarItemProvider extends Mutable {
*/ */
String nameForWidget(); String nameForWidget();
/**
* 模板决策报表 or cpt是否支持此工具栏按钮
* JTemplate 模板
* @return 支持返回true, 否则false
*/
@Override
boolean accept(JTemplate template);
} }

12
designer-base/src/main/java/com/fr/design/fun/impl/AbstractToolbarItem.java

@ -1,6 +1,9 @@
package com.fr.design.fun.impl; package com.fr.design.fun.impl;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.ToolbarItemProvider; import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API; import com.fr.stable.fun.mark.API;
@ -10,6 +13,7 @@ import com.fr.stable.fun.mark.API;
@API(level = ToolbarItemProvider.CURRENT_LEVEL) @API(level = ToolbarItemProvider.CURRENT_LEVEL)
public abstract class AbstractToolbarItem extends AbstractProvider implements ToolbarItemProvider { public abstract class AbstractToolbarItem extends AbstractProvider implements ToolbarItemProvider {
@Override
public int currentAPILevel() { public int currentAPILevel() {
return CURRENT_LEVEL; return CURRENT_LEVEL;
} }
@ -18,4 +22,12 @@ public abstract class AbstractToolbarItem extends AbstractProvider implements To
public String mark4Provider() { public String mark4Provider() {
return getClass().getName(); return getClass().getName();
} }
@Override
public boolean accept(JTemplate jTemplate) {
if (jTemplate == null) {
jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
}
return jTemplate == null || jTemplate.isJWorkBook() || jTemplate instanceof JVirtualTemplate;
}
} }

70
designer-base/src/test/java/com/fr/design/ExtraDesignClassManagerTest.java

@ -0,0 +1,70 @@
package com.fr.design;
import com.fr.config.dao.DaoContext;
import com.fr.config.dao.impl.LocalClassHelperDao;
import com.fr.config.dao.impl.LocalEntityDao;
import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.gui.core.WidgetOption;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.general.ModuleContext;
import com.fr.log.FineLoggerFactory;
import com.fr.report.restriction.CellCountRestriction;
import com.fr.report.restriction.ReportRestrictionScene;
import com.fr.restriction.Restrictions;
import com.fr.stable.Filter;
import com.fr.stable.module.Module;
import junit.framework.TestCase;
import org.easymock.EasyMock;
import org.junit.Assert;
import java.util.HashSet;
import java.util.Set;
/**
* @author zack
* @version 10.0
* Created by zack on 2019/9/17
*/
public class ExtraDesignClassManagerTest extends TestCase {
@Override
protected void setUp() throws Exception {
DaoContext.setEntityDao(new LocalEntityDao());
DaoContext.setClassHelperDao(new LocalClassHelperDao());
DaoContext.setXmlEntityDao(new LocalXmlEntityDao());
ModuleContext.startModule(Module.PAGE_MODULE);
Restrictions.register(ReportRestrictionScene.CELL_COUNT, new CellCountRestriction());
}
public void testGetWebOption() {
try {
final JTemplate jTemplate = new JVirtualTemplate(null);
ToolbarItemProvider item = EasyMock.mock(ToolbarItemProvider.class);
ToolbarItemProvider item1 = EasyMock.mock(ToolbarItemProvider.class);
EasyMock.expect(item.accept(jTemplate)).andReturn(false).anyTimes();
EasyMock.expect(item.classForWidget()).andReturn(null).anyTimes();
EasyMock.expect(item.iconPathForWidget()).andReturn("").anyTimes();
EasyMock.expect(item.nameForWidget()).andReturn("1").anyTimes();
EasyMock.expect(item1.accept(jTemplate)).andReturn(true).anyTimes();
EasyMock.expect(item1.classForWidget()).andReturn(null).anyTimes();
EasyMock.expect(item1.iconPathForWidget()).andReturn("").anyTimes();
EasyMock.expect(item1.nameForWidget()).andReturn("2").anyTimes();
EasyMock.replay(item);
EasyMock.replay(item1);
Set<ToolbarItemProvider> set = new HashSet<>();
set.add(item);
set.add(item1);
WidgetOption[] widgetOptions = ExtraDesignClassManager.getInstance().getWebWidgetOptions(set, new Filter<ToolbarItemProvider>() {
@Override
public boolean accept(ToolbarItemProvider toolbarItemProvider) {
return toolbarItemProvider.accept(jTemplate);
}
});
Assert.assertEquals(1, widgetOptions.length);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}

11
designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleElementCaseToolBarEditor.java

@ -1,13 +1,17 @@
package com.fr.design.mainframe.widget.accessibles; package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
import com.fr.design.mainframe.FormWebWidgetConstants; import com.fr.design.mainframe.FormWebWidgetConstants;
import com.fr.design.mainframe.widget.editors.ElementCaseToolBarPane; import com.fr.design.mainframe.widget.editors.ElementCaseToolBarPane;
import com.fr.design.mainframe.widget.wrappers.ElementCaseToolBarWrapper; import com.fr.design.mainframe.widget.wrappers.ElementCaseToolBarWrapper;
import com.fr.form.web.FormToolBarManager; import com.fr.form.web.FormToolBarManager;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Filter;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.util.ArrayList; import java.util.ArrayList;
@ -52,6 +56,13 @@ public class AccessibleElementCaseToolBarEditor extends UneditableAccessibleEdit
List<WidgetOption> defaultOptions = Arrays.asList(FormWebWidgetConstants.getFormElementCaseToolBarInstance()); List<WidgetOption> defaultOptions = Arrays.asList(FormWebWidgetConstants.getFormElementCaseToolBarInstance());
List<WidgetOption> options = new ArrayList<WidgetOption>(); List<WidgetOption> options = new ArrayList<WidgetOption>();
options.addAll(defaultOptions); options.addAll(defaultOptions);
WidgetOption[] widgetOptions = ExtraDesignClassManager.getInstance().getWebWidgetOptions(new Filter<ToolbarItemProvider>() {
@Override
public boolean accept(ToolbarItemProvider toolbarItemProvider) {
return toolbarItemProvider.accept(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
}
});
options.addAll(Arrays.asList(widgetOptions));
return options.toArray(new WidgetOption[options.size()]); return options.toArray(new WidgetOption[options.size()]);
} }

20
designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java

@ -24,6 +24,7 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.widget.accessibles.AccessibleBackgroundEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleBackgroundEditor;
import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.ui.designer.AbstractDataModify; import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.design.widget.ui.designer.component.UIBoundSpinner;
import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.Background; import com.fr.general.Background;
@ -61,7 +62,7 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
public void initComponent() { public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
designerWidth = new UISpinner(1, Integer.MAX_VALUE, 1); designerWidth = new UIBoundSpinner(1, Integer.MAX_VALUE, 1);
JPanel advancePane = createAdvancePane(); JPanel advancePane = createAdvancePane();
UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane); UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane);
this.add(advanceExpandablePane, BorderLayout.NORTH); this.add(advanceExpandablePane, BorderLayout.NORTH);
@ -162,16 +163,29 @@ public class RootDesignDefinePane extends AbstractDataModify<WParameterLayout> {
public WParameterLayout updateBean() { public WParameterLayout updateBean() {
WParameterLayout wParameterLayout = (WParameterLayout) creator.toData(); WParameterLayout wParameterLayout = (WParameterLayout) creator.toData();
wParameterLayout.setLabelName(labelNameTextField.getText()); wParameterLayout.setLabelName(labelNameTextField.getText());
wParameterLayout.setDesignWidth((int) designerWidth.getValue()); if (isCompsOutOfDesignerWidth((int) designerWidth.getValue())) {
designerWidth.setValue(wParameterLayout.getDesignWidth());
} else {
wParameterLayout.setDesignWidth((int) designerWidth.getValue());
}
wParameterLayout.setDelayDisplayContent(displayReport.isSelected()); wParameterLayout.setDelayDisplayContent(displayReport.isSelected());
wParameterLayout.setUseParamsTemplate(useParamsTemplate.isSelected()); wParameterLayout.setUseParamsTemplate(useParamsTemplate.isSelected());
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected()); jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected());
wParameterLayout.setBackground((Background) background.getValue()); wParameterLayout.setBackground((Background) background.getValue());
wParameterLayout.setPosition((int)hAlignmentPane.getSelectedItem()); wParameterLayout.setPosition((int) hAlignmentPane.getSelectedItem());
return wParameterLayout; return wParameterLayout;
} }
private boolean isCompsOutOfDesignerWidth(int designerWidth){
for(int i=0; i<root.getComponentCount(); i++){
Component comp = root.getComponent(i);
if(comp.getX() + comp.getWidth() > designerWidth){
return true;
}
}
return false;
}
@Override @Override
public DataCreatorUI dataUI() { public DataCreatorUI dataUI() {
return null; return null;

203
designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

@ -1,13 +1,12 @@
/**
*
*/
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.errorinfo.ErrorInfoUploader; import com.fr.design.mainframe.errorinfo.ErrorInfoUploader;
import com.fr.design.mainframe.messagecollect.impl.FocusPointMessageUploader; import com.fr.design.mainframe.messagecollect.impl.FocusPointMessageUploader;
import com.fr.design.mainframe.messagecollect.solid.SolidCollector;
import com.fr.design.mainframe.template.info.TemplateInfoCollector; import com.fr.design.mainframe.template.info.TemplateInfoCollector;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -29,6 +28,7 @@ import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException; import com.fr.third.javax.xml.stream.XMLStreamException;
import com.sun.management.OperatingSystemMXBean;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -42,6 +42,8 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.management.ManagementFactory;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -52,15 +54,19 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
* @author neil * 设计器信息收集
* *
* @author neil
* @date: 2015-4-8-下午5:11:46 * @date: 2015-4-8-下午5:11:46
*/ */
public class InformationCollector implements XMLReadable, XMLWriter { public class InformationCollector implements XMLReadable, XMLWriter {
// 24小时上传一次 /**
* 24小时上传一次
*/
private static final long DELTA = 24 * 3600 * 1000L; private static final long DELTA = 24 * 3600 * 1000L;
private static final long SEND_DELAY = 300 * 1000L; private static final long SEND_DELAY = 300 * 1000L;
private static final int BYTE_TO_MB = 1024 * 1024;
private static final String FILE_NAME = "fr.info"; private static final String FILE_NAME = "fr.info";
private static final String XML_START_STOP_LIST = "StartStopList"; private static final String XML_START_STOP_LIST = "StartStopList";
private static final String XML_START_STOP = "StartStop"; private static final String XML_START_STOP = "StartStop";
@ -73,26 +79,33 @@ public class InformationCollector implements XMLReadable, XMLWriter {
private static final String XML_UUID = "UUID"; private static final String XML_UUID = "UUID";
private static final String XML_KEY = "ActiveKey"; private static final String XML_KEY = "ActiveKey";
private static final String XML_OS = "OS"; private static final String XML_OS = "OS";
private static final String XML_ARCH = "arch";
private static final String XML_AVAILABLE_PROCESSORS = "cpu";
private static final String XML_PHYSICAL_MEMORY = "systemMemory";
private static InformationCollector collector; private static InformationCollector collector;
//启动时间与关闭时间列表 /**
private List<StartStopTime> startStop = new ArrayList<StartStopTime>(); * 启动时间与关闭时间列表
//上一次的发送时间 */
private List<StartStopTime> startStop = new ArrayList<>();
/**
* 上一次的发送时间
*/
private String lastTime; private String lastTime;
private StartStopTime current = new StartStopTime(); private StartStopTime current = new StartStopTime();
public static InformationCollector getInstance(){ public static InformationCollector getInstance() {
if (collector == null) { if (collector == null) {
collector = new InformationCollector(); collector = new InformationCollector();
readEncodeXMLFile(collector, collector.getInfoFile()); readEncodeXMLFile(collector, collector.getInfoFile());
} }
return collector; return collector;
} }
private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile){ private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile) {
if (xmlFile == null || !xmlFile.exists()) { if (xmlFile == null || !xmlFile.exists()) {
return; return;
} }
@ -118,13 +131,13 @@ public class InformationCollector implements XMLReadable, XMLWriter {
} }
private static String getDecodeFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException{ private static String getDecodeFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException {
InputStream encodeInputStream = new FileInputStream(xmlFile); InputStream encodeInputStream = new FileInputStream(xmlFile);
String encodeContent = IOUtils.inputStream2String(encodeInputStream); String encodeContent = IOUtils.inputStream2String(encodeInputStream);
return DesUtils.getDecString(encodeContent); return DesUtils.getDecString(encodeContent);
} }
private long getLastTimeMillis(){ private long getLastTimeMillis() {
if (StringUtils.isEmpty(this.lastTime)) { if (StringUtils.isEmpty(this.lastTime)) {
return 0; return 0;
} }
@ -141,23 +154,36 @@ public class InformationCollector implements XMLReadable, XMLWriter {
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
JSONArray startStopArray = new JSONArray(); JSONArray startStopArray = new JSONArray();
for (int i = 0; i < startStop.size(); i++) { for (StartStopTime startStopTime : startStop) {
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
jo.put(ATTR_START, startStop.get(i).getStartDate()); jo.put(ATTR_START, startStopTime.getStartDate());
jo.put(ATTR_STOP, startStop.get(i).getStopDate()); jo.put(ATTR_STOP, startStopTime.getStopDate());
startStopArray.put(jo); startStopArray.put(jo);
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
content.put(XML_START_STOP, startStopArray);
content.put(XML_UUID, envManager.getUUID());
content.put(XML_JAR, GeneralUtils.readBuildNO());
content.put(XML_VERSION, ProductConstants.RELEASE_VERSION);
content.put(XML_USERNAME, MarketConfig.getInstance().getBbsUsername());
content.put(XML_KEY, envManager.getActivationKey());
content.put(XML_OS, System.getProperty("os.name"));
} }
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
content.put(XML_START_STOP, startStopArray);
content.put(XML_UUID, envManager.getUUID());
content.put(XML_JAR, GeneralUtils.readBuildNO());
content.put(XML_VERSION, ProductConstants.RELEASE_VERSION);
content.put(XML_USERNAME, MarketConfig.getInstance().getBbsUsername());
content.put(XML_KEY, envManager.getActivationKey());
content.put(XML_OS, System.getProperty("os.name"));
content.put(XML_ARCH, System.getProperty("os.arch"));
content.put(XML_AVAILABLE_PROCESSORS, Runtime.getRuntime().availableProcessors());
content.put(XML_PHYSICAL_MEMORY, getTotalPhysicalMemorySize());
return content; return content;
} }
/**
* 获取物理内存单位GB
*
* @return 物理内存
*/
private static long getTotalPhysicalMemorySize() {
OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
return bean.getTotalPhysicalMemorySize() / BYTE_TO_MB;
}
private void sendUserInfo(){ private void sendUserInfo(){
long currentTime = new Date().getTime(); long currentTime = new Date().getTime();
long lastTime = getLastTimeMillis(); long lastTime = getLastTimeMillis();
@ -185,21 +211,22 @@ public class InformationCollector implements XMLReadable, XMLWriter {
/** /**
* 收集开始使用时间发送信息 * 收集开始使用时间发送信息
*/ */
public void collectStartTime(){ public void collectStartTime() {
this.current.setStartDate(dateToString()); this.current.setStartDate(dateToString());
sendUserInfoInOtherThread(); sendUserInfoInOtherThread();
} }
private void sendUserInfoInOtherThread(){ private void sendUserInfoInOtherThread() {
if (!DesignerEnvManager.getEnvManager().isJoinProductImprove() || !FRContext.isChineseEnv()) { if (!DesignerEnvManager.getEnvManager().isJoinProductImprove() || !FRContext.isChineseEnv()) {
return; return;
} }
ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(); ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("InformationCollector"));
service.schedule(new Runnable() { service.schedule(new Runnable() {
@Override @Override
public void run() { public void run() {
SolidCollector.getInstance().sendToCloudCenterAndDeleteFile();
sendUserInfo(); sendUserInfo();
FocusPointMessageUploader.getInstance().sendToCloudCenter(); FocusPointMessageUploader.getInstance().sendToCloudCenter();
TemplateInfoCollector.getInstance().sendTemplateInfo(); TemplateInfoCollector.getInstance().sendTemplateInfo();
@ -208,67 +235,66 @@ public class InformationCollector implements XMLReadable, XMLWriter {
}, SEND_DELAY, TimeUnit.MILLISECONDS); }, SEND_DELAY, TimeUnit.MILLISECONDS);
} }
/** /**
* 收集结束使用时间 * 收集结束使用时间
*/ */
public void collectStopTime(){ public void collectStopTime() {
this.current.setStopDate(dateToString()); this.current.setStopDate(dateToString());
} }
private String dateToString(){ private String dateToString() {
DateFormat df = FRContext.getDefaultValues().getDateTimeFormat(); DateFormat df = FRContext.getDefaultValues().getDateTimeFormat();
return df.format(new Date()); return df.format(new Date());
} }
private void reset(){ private void reset() {
this.startStop.clear(); this.startStop.clear();
this.lastTime = dateToString(); this.lastTime = dateToString();
} }
private File getInfoFile() { private File getInfoFile() {
return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME)); return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME));
} }
/** /**
* 保存xml文件 * 保存xml文件
*/ */
public void saveXMLFile() { public void saveXMLFile() {
File xmlFile = this.getInfoFile(); File xmlFile = this.getInfoFile();
try{ try {
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLTools.writeOutputStreamXML(this, out); XMLTools.writeOutputStreamXML(this, out);
out.flush(); out.flush();
out.close(); out.close();
String fileContent = new String(out.toByteArray(), EncodeConstants.ENCODING_UTF_8); String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8);
String encodeCotent = DesUtils.getEncString(fileContent); String encodeCotent = DesUtils.getEncString(fileContent);
writeEncodeContentToFile(encodeCotent, xmlFile); writeEncodeContentToFile(encodeCotent, xmlFile);
}catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
/** /**
* 将文件内容写到输出流中 * 将文件内容写到输出流中
*/ */
private static void writeEncodeContentToFile(String fileContent, File file){ private static void writeEncodeContentToFile(String fileContent, File file) {
BufferedWriter bw = null; BufferedWriter bw = null;
try { try {
FileOutputStream fos = new FileOutputStream(file); FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos, EncodeConstants.ENCODING_UTF_8); OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
bw = new BufferedWriter(osw); bw = new BufferedWriter(osw);
bw.write(fileContent); bw.write(fileContent);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally { } finally {
if(bw != null){ if (bw != null) {
try { try {
bw.close(); bw.close();
} catch (IOException e) { } catch (IOException ignore) {
} }
} }
} }
} }
@Override @Override
@ -283,56 +309,57 @@ public class InformationCollector implements XMLReadable, XMLWriter {
writer.end(); writer.end();
} }
private void writeStartStopList(XMLPrintWriter writer){ private void writeStartStopList(XMLPrintWriter writer) {
//启停 //启停
writer.startTAG(XML_START_STOP_LIST); writer.startTAG(XML_START_STOP_LIST);
for (int i = 0; i < startStop.size(); i++) { for (StartStopTime startStopTime : startStop) {
startStop.get(i).writeXML(writer); startStopTime.writeXML(writer);
} }
writer.end(); writer.end();
} }
private void writeTag(String tag, String content, XMLPrintWriter writer){ private void writeTag(String tag, String content, XMLPrintWriter writer) {
if (StringUtils.isEmpty(content)) { if (StringUtils.isEmpty(content)) {
return; return;
} }
writer.startTAG(tag); writer.startTAG(tag);
writer.textNode(content); writer.textNode(content);
writer.end(); writer.end();
} }
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (reader.isChildNode()) { if (reader.isChildNode()) {
String name = reader.getTagName(); String name = reader.getTagName();
if (XML_START_STOP_LIST.equals(name)) { if (XML_START_STOP_LIST.equals(name)) {
readStartStopList(reader); readStartStopList(reader);
} else if(XML_LAST_TIME.equals(name)){ } else if (XML_LAST_TIME.equals(name)) {
readLastTime(reader); readLastTime(reader);
} }
} }
} }
private void readLastTime(XMLableReader reader){ private void readLastTime(XMLableReader reader) {
String tmpVal; String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) { if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.lastTime = tmpVal; this.lastTime = tmpVal;
} }
} }
private void readStartStopList(XMLableReader reader){ private void readStartStopList(XMLableReader reader) {
startStop.clear(); startStop.clear();
reader.readXMLObject(new XMLReadable() { reader.readXMLObject(new XMLReadable() {
public void readXML(XMLableReader reader) { @Override
if (XML_START_STOP.equals(reader.getTagName())) { public void readXML(XMLableReader reader) {
StartStopTime startStopTime = new StartStopTime(); if (XML_START_STOP.equals(reader.getTagName())) {
reader.readXMLObject(startStopTime); StartStopTime startStopTime = new StartStopTime();
startStop.add(startStopTime); reader.readXMLObject(startStopTime);
} startStop.add(startStopTime);
} }
}); }
});
} }
private class StartStopTime implements XMLReadable, XMLWriter { private class StartStopTime implements XMLReadable, XMLWriter {
@ -356,17 +383,19 @@ public class InformationCollector implements XMLReadable, XMLWriter {
this.stopDate = endDate; this.stopDate = endDate;
} }
@Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_START_STOP); writer.startTAG(XML_START_STOP);
if (StringUtils.isNotEmpty(startDate)) { if (StringUtils.isNotEmpty(startDate)) {
writer.attr(ATTR_START, this.startDate); writer.attr(ATTR_START, this.startDate);
} }
if (StringUtils.isNotEmpty(stopDate)) { if (StringUtils.isNotEmpty(stopDate)) {
writer.attr(ATTR_STOP, this.stopDate); writer.attr(ATTR_STOP, this.stopDate);
} }
writer.end(); writer.end();
} }
@Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
this.startDate = reader.getAttrAsString(ATTR_START, StringUtils.EMPTY); this.startDate = reader.getAttrAsString(ATTR_START, StringUtils.EMPTY);
this.stopDate = reader.getAttrAsString(ATTR_STOP, StringUtils.EMPTY); this.stopDate = reader.getAttrAsString(ATTR_STOP, StringUtils.EMPTY);

92
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java

@ -0,0 +1,92 @@
package com.fr.design.mainframe.messagecollect;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.SiteCenterToken;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.module.ModuleContext;
import com.fr.module.engine.FineModule;
import com.fr.runtime.FineRuntime;
import com.fr.stable.StringUtils;
import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 启动信息收集
*
* @author vito
* @version 10.0
* Created by vito on 2019/9/4
*/
public class StartupMessageCollector {
private static final String XML_STARTUP_TIME = "t";
private static final String XML_STARTUP_LOG = "startupLog";
private static final String XML_STARTUP_Memory = "designerMemory";
private static final String XML_STARTUP_COST = "cost";
private static final String XML_UUID = "UUID";
private static final String STARTUP_URL_KEY = "user.info.v10.startup";
private static final String LOG_TYPE = "single";
private static final int BYTE_TO_MB = 1024 * 1024;
public static final StartupMessageCollector INSTANCE = new StartupMessageCollector();
private StartupMessageCollector() {
}
public static StartupMessageCollector getInstance() {
return INSTANCE;
}
public void recordStartupLog() {
EventDispatcher.listen(FineRuntime.ApplicationEvent.AFTER_START, new Listener<Long>() {
@Override
public void on(Event event, Long param) {
final String url = CloudCenter.getInstance().acquireUrlByKind(STARTUP_URL_KEY);
if (StringUtils.isEmpty(url)) {
return;
}
ExecutorService es = Executors.newSingleThreadExecutor(new NamedThreadFactory("StartupMessageCollector"));
es.submit(new Runnable() {
@Override
public void run() {
FineModule root = (FineModule) ModuleContext.getRoot().getRoot();
JSONObject profile = root.profile();
JSONObject json = JSONObject.create()
.put(XML_UUID, DesignerEnvManager.getEnvManager().getUUID())
.put(XML_STARTUP_TIME, FineRuntime.getAppStartTime() + FineRuntime.getStartingTime())
.put(XML_STARTUP_COST, FineRuntime.getStartingTime())
.put(XML_STARTUP_LOG, profile)
.put(XML_STARTUP_Memory, Runtime.getRuntime().totalMemory() / BYTE_TO_MB);
sendInfo(json, url + LOG_TYPE);
}
});
es.shutdown();
}
});
}
private boolean sendInfo(JSONObject content, String url) {
boolean success = false;
try {
HashMap<String, Object> para = new HashMap<>();
para.put("token", SiteCenterToken.generateToken());
para.put("content", content);
String res = HttpToolbox.post(url, para);
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return success;
}
}

18
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollectConstants.java

@ -0,0 +1,18 @@
package com.fr.design.mainframe.messagecollect.solid;
/**
* Created by alex sung on 2019/9/5.
*/
public class SolidCollectConstants {
private SolidCollectConstants(){}
/**
* 客户端请求subject
*/
public static final String REQUEST_SUBJECT = "solid";
/**
* 客户端请求超时鉴权时间默认1h失效
*/
public static final long TIME_OUT = 60 * 60 * 1000;
}

97
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java

@ -0,0 +1,97 @@
package com.fr.design.mainframe.messagecollect.solid;
import com.fr.general.CloudCenter;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.security.JwtUtils;
import com.fr.stable.CommonUtils;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants.REQUEST_SUBJECT;
import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants.TIME_OUT;
/**
* 设计器固化信息回传类
* Created by alex sung on 2019/8/22.
*/
public class SolidCollector {
private static final String CONTENT_URL = "/v10/collect/solid";
private static final String DELETE_URL = "/v10/collect/solid/delete";
private static final String UNLOCK_URL = "/v10/collect/solid/unlock";
private static final String ATTR_CIPHER_TEXT = "cipherText";
private static final String ATTR_SIGNATURE = "signature";
private static final String SOLID_UPLOAD_URL = CloudCenter.getInstance().acquireUrlByKind("design.solid");
private static volatile SolidCollector instance;
public static SolidCollector getInstance() {
if (instance == null) {
synchronized (SolidCollector.class) {
if (instance == null) {
instance = new SolidCollector();
}
}
}
return instance;
}
/**
* 回传文件给云中心并删除服务端本地文件
*/
public void sendToCloudCenterAndDeleteFile() {
if (WorkContext.getCurrent().isLocal()) {
return;
}
FineLoggerFactory.getLogger().info("start to get solid content from server...");
try {
String content = requestContent();
if (StringUtils.isNotEmpty(content)) {
String cipherText = JSONFactory.createJSON(JSON.OBJECT, content).optString("data");
if(StringUtils.isNotEmpty(cipherText)){
Map<String, Object> params = new HashMap<>();
params.put(ATTR_CIPHER_TEXT, cipherText);
params.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature()));
HttpToolbox.post(SOLID_UPLOAD_URL, params);
String deleteUrl = WorkContext.getCurrent().getPath() + DELETE_URL;
HttpToolbox.post(deleteUrl, getParams());
}
}
FineLoggerFactory.getLogger().info("send solid content to cloud center success.");
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage(), e);
} finally {
String unlockUrl = WorkContext.getCurrent().getPath() + UNLOCK_URL;
try {
HttpToolbox.post(unlockUrl, getParams());
} catch (IOException e) {
FineLoggerFactory.getLogger().warn(e.getMessage(), e);
}
}
}
/**
* 获取服务端固化文件内容
* @return 回传内容
*/
public String requestContent() throws Exception {
Map<String, String> params = new HashMap<String, String>();
params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT));
return HttpToolbox.get(WorkContext.getCurrent().getPath() + CONTENT_URL, params);
}
private Map<String, Object> getParams() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT));
return params;
}
}

20
designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java

@ -27,6 +27,7 @@ import com.fr.design.selection.SelectionListener;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection; import com.fr.grid.selection.Selection;
import com.fr.report.cell.TemplateCellElement;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import com.fr.stable.ColumnRowGroup; import com.fr.stable.ColumnRowGroup;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -454,11 +455,22 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
newAdd.clear(); newAdd.clear();
for (int i = 0; i < cs; i++) { for (int i = 0; i < cs; i++) {
for (int j = 0; j < rs; j++) { for (int j = 0; j < rs; j++) {
ColumnRow columnRow = ColumnRow.valueOf(c + i, r + j); TemplateCellElement cellElement = ePane.getEditingElementCase().getTemplateCellElement(c + i, r + j );
if (!allColumnRow.contains(columnRow.toString())) { if (cellElement != null && ((i + c) != 0 || (r + j) != 0)) {
add.addColumnRow(columnRow); String value = cellElement.toString();
if (!newAdd.contains(value) && !allColumnRow.contains(value)) {
add.addColumnRow(ColumnRow.valueOf(value));
}
newAdd.add(value);
}
if (cellElement == null) {
ColumnRow columnRow = ColumnRow.valueOf(c + i, r + j);
if (!allColumnRow.contains(columnRow.toString())) {
add.addColumnRow(columnRow);
}
newAdd.add(columnRow.toString());
} }
newAdd.add(columnRow.toString());
} }
} }
int oldSize = oldAdd.size(); int oldSize = oldAdd.size();

2
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java

@ -103,7 +103,7 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
formulaButton.addActionListener(new ActionListener() { formulaButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
String text = formulaTextField.getText(); String text = formulaTextField.getText();
final UIFormula formulaPane = FormulaFactory.createFormulaPane(); final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula();
formulaPane.populate(BaseFormula.createFormulaBuilder().build(text)); formulaPane.populate(BaseFormula.createFormulaBuilder().build(text));
formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override @Override

11
designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

@ -1,14 +1,15 @@
package com.fr.start.module; package com.fr.start.module;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.messagecollect.StartupMessageCollector;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.module.Activator; import com.fr.module.Activator;
import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.EnableMetrics;
import com.fr.record.analyzer.Metrics; import com.fr.record.analyzer.Metrics;
import com.fr.runtime.FineRuntime;
import com.fr.start.Designer; import com.fr.start.Designer;
import com.fr.start.ServerStarter; import com.fr.start.ServerStarter;
import com.fr.start.SplashContext; import com.fr.start.SplashContext;
@ -42,7 +43,7 @@ public class DesignerStartup extends Activator {
startSub(EnvBasedModule.class); startSub(EnvBasedModule.class);
//designer模块启动好后,查看demo //designer模块启动好后,查看demo
browserDemo(); browserDemo();
ExecutorService service = Executors.newFixedThreadPool(2); ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("FineEmbedServerStart"));
service.submit(new Runnable() { service.submit(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -67,7 +68,7 @@ public class DesignerStartup extends Activator {
DesignerContext.getDesignerFrame().getProgressDialog().setVisible(true); DesignerContext.getDesignerFrame().getProgressDialog().setVisible(true);
startSub(StartFinishActivator.class); startSub(StartFinishActivator.class);
FineRuntime.startFinish(); StartupMessageCollector.getInstance().recordStartupLog();
} }
private void browserDemo() { private void browserDemo() {
@ -87,7 +88,7 @@ public class DesignerStartup extends Activator {
@Override @Override
public void on(Event event, Workspace current) { public void on(Event event, Workspace current) {
getSub(EnvBasedModule.class).stop(); stopSub(EnvBasedModule.class);
} }
}); });
/*切换环境后,重新启动所有相关模块,最先执行*/ /*切换环境后,重新启动所有相关模块,最先执行*/
@ -95,7 +96,7 @@ public class DesignerStartup extends Activator {
@Override @Override
public void on(Event event, Workspace current) { public void on(Event event, Workspace current) {
getSub(EnvBasedModule.class).start(); startSub(EnvBasedModule.class);
// 切换后的环境是本地环境才启动内置服务器 // 切换后的环境是本地环境才启动内置服务器
if (current.isLocal()) { if (current.isLocal()) {
ExecutorService service = Executors.newSingleThreadExecutor(); ExecutorService service = Executors.newSingleThreadExecutor();

Loading…
Cancel
Save