Browse Source

Merge remote-tracking branch 'origin/feature/10.0' into feature/10.0

persist/11.0
Bruce.Deng 5 years ago
parent
commit
6f2dd2cb93
  1. 3
      designer-base/src/main/java/com/fr/design/gui/frpane/UINumberSlidePane.java
  2. 3
      designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java
  3. 13
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  4. 4
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  5. 11
      designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java
  6. 3
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  7. 6
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java
  8. 22
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java
  9. 31
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  10. 11
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  11. 3
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  12. 12
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  13. 31
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPane.java
  14. 6
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java
  15. 4
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java
  16. 55
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java
  17. 5
      designer-sdk/pom.xml
  18. 80
      designer-sdk/src/main/java/com/fr/sdk/designer/FineDesignUtils.java
  19. 7
      designer-sdk/src/test/java/com/fr/sdk/FineDesignUtilsTest.java

3
designer-base/src/main/java/com/fr/design/gui/frpane/UINumberSlidePane.java

@ -14,6 +14,7 @@ import javax.swing.event.ChangeListener;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.gui.style.NumberDragBar; import com.fr.design.gui.style.NumberDragBar;
import com.fr.stable.AssistUtils;
/** /**
* 拖拽的滑条和对应滑条值的数字 * 拖拽的滑条和对应滑条值的数字
@ -65,7 +66,7 @@ public class UINumberSlidePane extends BasicBeanPane<Double> {
public void checkValue(double value) { public void checkValue(double value) {
value = Math.max(value, minValue); value = Math.max(value, minValue);
value = Math.min(value, maxValue); value = Math.min(value, maxValue);
if (this.value == value) { if (AssistUtils.equals(this.value, value)) {
return; return;
} }
double diff = Math.abs(value - this.value); double diff = Math.abs(value - this.value);

3
designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java

@ -10,6 +10,7 @@ import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
@ -81,7 +82,7 @@ public abstract class UnitInputPane extends BasicPane {
floatValue = de.floatValue(); floatValue = de.floatValue();
} }
//选中多列, 并且列宽不完全一致的话, 就不显示值了. //选中多列, 并且列宽不完全一致的话, 就不显示值了.
temp.setText(floatValue == 0 ? StringUtils.EMPTY : Utils.convertNumberStringToString(new Float(floatValue))); temp.setText(AssistUtils.equals(floatValue, 0) ? StringUtils.EMPTY : Utils.convertNumberStringToString(new Float(floatValue)));
// denny:默认应该为选中,方便用户修改 // denny:默认应该为选中,方便用户修改
temp.selectAll(); temp.selectAll();

13
designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

@ -35,6 +35,7 @@ import com.fr.json.JSONArray;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -362,10 +363,10 @@ public class UpdateMainDialog extends UIDialog {
add(jarVersionInfoPane, BorderLayout.NORTH); add(jarVersionInfoPane, BorderLayout.NORTH);
//海外版本不显示更新信息 //海外版本不显示更新信息
if (GeneralContext.getLocale().equals(Locale.CHINA) || GeneralContext.getLocale().equals(Locale.TAIWAN)){ if (GeneralContext.getLocale().equals(Locale.CHINA) || GeneralContext.getLocale().equals(Locale.TAIWAN)) {
add(jarUpdateInfoPane, BorderLayout.CENTER); add(jarUpdateInfoPane, BorderLayout.CENTER);
add(updateActionPane, BorderLayout.SOUTH); add(updateActionPane, BorderLayout.SOUTH);
}else { } else {
add(updateActionPane, BorderLayout.CENTER); add(updateActionPane, BorderLayout.CENTER);
} }
@ -513,16 +514,15 @@ public class UpdateMainDialog extends UIDialog {
if (endTime.equals(lastUpdateCacheTime) || jsonArray.length() == 0 || ComparatorUtils.compare(endTime, lastUpdateCacheTime) <= 0) { if (endTime.equals(lastUpdateCacheTime) || jsonArray.length() == 0 || ComparatorUtils.compare(endTime, lastUpdateCacheTime) <= 0) {
return; return;
} }
OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), "UTF-8"); try (OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), EncodeConstants.ENCODING_UTF_8);
BufferedWriter bufferWriter = new BufferedWriter(writerStream); BufferedWriter bufferWriter = new BufferedWriter(writerStream)) {
for (int i = 0; i < jsonArray.length(); i++) { for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jo = (JSONObject) jsonArray.get(i); JSONObject jo = (JSONObject) jsonArray.get(i);
bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title")); bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title"));
bufferWriter.newLine(); bufferWriter.newLine();
bufferWriter.flush(); bufferWriter.flush();
} }
bufferWriter.close(); }
writerStream.close();
lastUpdateCacheState = UPDATE_CACHE_STATE_SUCCESS; lastUpdateCacheState = UPDATE_CACHE_STATE_SUCCESS;
lastUpdateCacheTime = endTime; lastUpdateCacheTime = endTime;
cacheProperty.updateProperty("updateTime", lastUpdateCacheTime); cacheProperty.updateProperty("updateTime", lastUpdateCacheTime);
@ -634,6 +634,7 @@ public class UpdateMainDialog extends UIDialog {
/** /**
* 获取当前jar的md5 * 获取当前jar的md5
*
* @param currentJAR * @param currentJAR
* @return * @return
*/ */

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

@ -67,8 +67,7 @@ public class DesignUtils {
* @return 启动了返回true * @return 启动了返回true
*/ */
public static boolean isStarted() { public static boolean isStarted() {
try { try (Socket socket = new Socket("localhost", port)) {
new Socket("localhost", port);
return true; return true;
} catch (Exception ignored) { } catch (Exception ignored) {
} }
@ -116,6 +115,7 @@ public class DesignUtils {
* @param startPort 端口 * @param startPort 端口
* @param suffixs 文件后缀 * @param suffixs 文件后缀
*/ */
@SuppressWarnings("squid:S2095")
public static void createListeningServer(final int startPort, final String[] suffixs) { public static void createListeningServer(final int startPort, final String[] suffixs) {
ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("DesignClientListener")); ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("DesignClientListener"));
service.execute(new Runnable() { service.execute(new Runnable() {

11
designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java

@ -86,12 +86,14 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent {
initDialog(); initDialog();
dialog.addWindowListener(new WindowAdapter() { dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
//取消下载 //取消下载
result = false; result = false;
exitDialog(); exitDialog();
} }
@Override
public void windowOpened(WindowEvent e) { public void windowOpened(WindowEvent e) {
downloadAndInstallPluginDependenceFile(); downloadAndInstallPluginDependenceFile();
exitDialog(); exitDialog();
@ -119,11 +121,11 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent {
httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteInfo.siteKind)); httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteInfo.siteKind));
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStream reader = httpClient.getResponseStream();
String temp = StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE); String temp = StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE);
File file = new File(temp); File file = new File(temp);
StableUtils.makesureFileExist(file); StableUtils.makesureFileExist(file);
FileOutputStream writer = new FileOutputStream(temp); try (InputStream reader = httpClient.getResponseStream();
FileOutputStream writer = new FileOutputStream(temp)) {
byte[] buffer = new byte[PluginConstants.BYTES_NUM]; byte[] buffer = new byte[PluginConstants.BYTES_NUM];
int bytesRead; int bytesRead;
while ((bytesRead = reader.read(buffer)) > 0 && result) { while ((bytesRead = reader.read(buffer)) > 0 && result) {
@ -133,11 +135,8 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent {
currentBytesRead += bytesRead; currentBytesRead += bytesRead;
setProgress(currentBytesRead); setProgress(currentBytesRead);
} }
reader.close();
writer.flush(); writer.flush();
writer.close(); }
if (result) { if (result) {
//安装文件 //安装文件
IOUtils.unZipFilesGBK(temp, StableUtils.pathJoin(WorkContext.getCurrent().getPath(), siteInfo.localDir)); IOUtils.unZipFilesGBK(temp, StableUtils.pathJoin(WorkContext.getCurrent().getPath(), siteInfo.localDir));

3
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -24,6 +24,7 @@ import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.WTabDisplayPosition;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.act.BorderPacker;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
@ -284,7 +285,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
backupBound.x -= rec.x; backupBound.x -= rec.x;
backupBound.y -= rec.y; backupBound.y -= rec.y;
XWCardLayout cardLayout = mainLayout.getCardPart(); XWCardLayout cardLayout = mainLayout.getCardPart();
LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); BorderPacker style = cardLayout.toData().getBorderStyle();
XWCardTitleLayout xwCardTitleLayout = mainLayout.getTitlePart(); XWCardTitleLayout xwCardTitleLayout = mainLayout.getTitlePart();
Dimension titleDimension = xwCardTitleLayout.getSize(); Dimension titleDimension = xwCardTitleLayout.getSize();

6
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java

@ -7,18 +7,16 @@ package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.beans.GroupModel; import com.fr.design.beans.GroupModel;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.XWidgetCreator; import com.fr.design.designer.creator.XWidgetCreator;
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;
import com.fr.design.designer.properties.FRTabFitLayoutPropertiesGroupModel; import com.fr.design.designer.properties.FRTabFitLayoutPropertiesGroupModel;
import com.fr.design.mainframe.widget.editors.ParameterEditor;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.act.BorderPacker;
import java.awt.*; import java.awt.*;
@ -90,7 +88,7 @@ public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter {
// TODO 可以直接在这边将x,y都变成相对坐标,这样在后面判断拖进来的新控件放置方式的时候就不用再判断了 // TODO 可以直接在这边将x,y都变成相对坐标,这样在后面判断拖进来的新控件放置方式的时候就不用再判断了
private int adjustY(int y, XWTabFitLayout tabLayout) { private int adjustY(int y, XWTabFitLayout tabLayout) {
XWCardLayout cardLayout = (XWCardLayout) tabLayout.getBackupParent(); XWCardLayout cardLayout = (XWCardLayout) tabLayout.getBackupParent();
LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); BorderPacker style = cardLayout.toData().getBorderStyle();
y = y - this.getParaEditorYOffset(); y = y - this.getParaEditorYOffset();
if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) {
y = y - WCardMainBorderLayout.TAB_HEIGHT; y = y - WCardMainBorderLayout.TAB_HEIGHT;

22
designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java

@ -11,6 +11,8 @@ import com.fr.form.ui.WidgetTitle;
import com.fr.form.ui.WidgetValue; import com.fr.form.ui.WidgetValue;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.act.BorderPacker;
import com.fr.general.act.TitlePacker;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -41,7 +43,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
} }
protected void initStyle() { protected void initStyle() {
LayoutBorderStyle style = toData().getBorderStyle(); BorderPacker style = toData().getBorderStyle();
initBorderStyle(); initBorderStyle();
if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) {
initTitleStyle(style); initTitleStyle(style);
@ -52,7 +54,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
// 边框默认值设为NONE,不然像scalelayout这种只用默认边框的会不显示边框 // 边框默认值设为NONE,不然像scalelayout这种只用默认边框的会不显示边框
protected void initBorderStyle() { protected void initBorderStyle() {
LayoutBorderStyle style = toData().getBorderStyle(); BorderPacker style = toData().getBorderStyle();
if (style != null && style.getBorder() != Constants.LINE_NONE) { if (style != null && style.getBorder() != Constants.LINE_NONE) {
this.setBorder(new UIRoundedBorder(style.getBorder(), style.getColor(), style.getBorderRadius())); this.setBorder(new UIRoundedBorder(style.getBorder(), style.getColor(), style.getBorderRadius()));
} else { } else {
@ -74,8 +76,8 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
* 设置样式为标题样式时对应组件加上标题 * 设置样式为标题样式时对应组件加上标题
* @param style 样式 * @param style 样式
*/ */
protected void initTitleStyle(LayoutBorderStyle style){ protected void initTitleStyle(BorderPacker style){
if (style.getTitle() == null) { if (style.getTitle() == null || style.getTitle().getTextObject() == null) {
return; return;
} }
XWTitleLayout parent = (XWTitleLayout) this.getParent(); XWTitleLayout parent = (XWTitleLayout) this.getParent();
@ -100,25 +102,25 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
/** /**
* 更新标题控件所有的样式 * 更新标题控件所有的样式
*/ */
private void updateTitleWidgetStyle(Label title, LayoutBorderStyle style) { private void updateTitleWidgetStyle(Label title, BorderPacker style) {
//标题的边框样式目前是取对应的控件的边框样式 //标题的边框样式目前是取对应的控件的边框样式
title.setBorder(style.getBorder()); title.setBorder(style.getBorder());
title.setColor(style.getColor()); title.setColor(style.getColor());
// title.setCorner(style.isCorner()); // title.setCorner(style.isCorner());
WidgetTitle wTitle = style.getTitle(); TitlePacker wTitle = style.getTitle();
//设置成随机不重复的, 不然都用一个名字的话, 联动只能联动一个 //设置成随机不重复的, 不然都用一个名字的话, 联动只能联动一个
title.setWidgetName(wTitle.TITLE_NAME_INDEX + this.toData().getWidgetName()); title.setWidgetName(WidgetTitle.TITLE_NAME_INDEX + this.toData().getWidgetName());
title.setWidgetValue(getTitleValue(wTitle)); title.setWidgetValue(getTitleValue(wTitle));
title.setFont(wTitle.getFrFont()); title.setFont(wTitle.getFrFont());
title.setTextalign(wTitle.getPosition()); title.setTextalign(wTitle.getPosition());
title.setBackground(wTitle.getBackground()); title.setBackground(wTitle.getBackground());
} }
private WidgetValue getTitleValue(WidgetTitle wTitle){ private WidgetValue getTitleValue(TitlePacker wTitle){
String content = String.valueOf(wTitle.getTextObject()); String content = String.valueOf(wTitle.getTextObject());
Object vlaue = content.startsWith("=") ? BaseFormula.createFormulaBuilder().build(content) : content; Object value = content.startsWith("=") ? BaseFormula.createFormulaBuilder().build(content) : content;
return new WidgetValue(vlaue); return new WidgetValue(value);
} }
@Override @Override

31
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java

@ -22,31 +22,20 @@ import com.fr.design.mainframe.JForm;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle;
import com.fr.form.ui.container.WTabTextDirection; import com.fr.form.ui.container.WTabTextDirection;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.general.act.BorderPacker;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.act.TitlePacker;
import com.fr.general.cardtag.TemplateStyle; import com.fr.general.cardtag.TemplateStyle;
import com.fr.stable.unit.PT; import com.fr.stable.unit.PT;
import javax.swing.Action; import javax.swing.*;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.plaf.basic.BasicLabelUI; import javax.swing.plaf.basic.BasicLabelUI;
import java.awt.Color; import java.awt.*;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.ArrayList; import java.util.ArrayList;
@ -308,7 +297,7 @@ public class XCardSwitchButton extends XButton {
super.paintComponent(g); super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
CardSwitchButton button = (CardSwitchButton) this.toData(); CardSwitchButton button = (CardSwitchButton) this.toData();
WidgetTitle widgetTitle = getWidgetTitle(); TitlePacker widgetTitle = getWidgetTitle();
drawBackground(button, widgetTitle); drawBackground(button, widgetTitle);
drawTitle(button, widgetTitle); drawTitle(button, widgetTitle);
Dimension panelSize = this.getContentLabel().getSize(); Dimension panelSize = this.getContentLabel().getSize();
@ -322,7 +311,7 @@ public class XCardSwitchButton extends XButton {
} }
//画背景 //画背景
private void drawBackground(CardSwitchButton button, WidgetTitle widgetTitle){ private void drawBackground(CardSwitchButton button, TitlePacker widgetTitle){
Background background = widgetTitle.getBackground() == null ? ColorBackground.getInstance(NORMAL_GRAL) : widgetTitle.getBackground(); Background background = widgetTitle.getBackground() == null ? ColorBackground.getInstance(NORMAL_GRAL) : widgetTitle.getBackground();
TemplateStyle templateStyle = ((WCardTagLayout) tagLayout.toData()).getTemplateStyle(); TemplateStyle templateStyle = ((WCardTagLayout) tagLayout.toData()).getTemplateStyle();
//获取当前tab的index //获取当前tab的index
@ -340,7 +329,7 @@ public class XCardSwitchButton extends XButton {
} }
//画标题 //画标题
private void drawTitle(CardSwitchButton button, WidgetTitle widgetTitle) { private void drawTitle(CardSwitchButton button, TitlePacker widgetTitle) {
String titleText = button.getText(); String titleText = button.getText();
this.setButtonText(titleText); this.setButtonText(titleText);
FRFont font = widgetTitle.getFrFont(); FRFont font = widgetTitle.getFrFont();
@ -351,11 +340,11 @@ public class XCardSwitchButton extends XButton {
} }
private WidgetTitle getWidgetTitle() { private TitlePacker getWidgetTitle() {
if (this.cardLayout == null) { if (this.cardLayout == null) {
initRelateLayout(); initRelateLayout();
} }
LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle(); BorderPacker style = this.cardLayout.toData().getBorderStyle();
return style.getTitle(); return style.getTitle();
} }
@ -463,7 +452,7 @@ public class XCardSwitchButton extends XButton {
String titleText = button.getText(); String titleText = button.getText();
java.util.List verticalTextList = new ArrayList(); java.util.List verticalTextList = new ArrayList();
StringBuilder titleStringBuf = new StringBuilder(); StringBuilder titleStringBuf = new StringBuilder();
WidgetTitle title = getWidgetTitle(); TitlePacker title = getWidgetTitle();
FRFont font = title.getFrFont(); FRFont font = title.getFrFont();
FRFont newFont = FRFont.getInstance(font.getName(), font.getStyle(), font.getSize() + FONT_SIZE_ADJUST); FRFont newFont = FRFont.getInstance(font.getName(), font.getStyle(), font.getSize() + FONT_SIZE_ADJUST);
FontMetrics fm = GraphHelper.getFontMetrics(newFont); FontMetrics fm = GraphHelper.getFontMetrics(newFont);

11
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -25,7 +25,6 @@ import com.fr.form.ui.CardAddButton;
import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetTitle;
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;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
@ -33,7 +32,9 @@ import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.form.ui.container.cardlayout.WCardTitleLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.act.BorderPacker;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.act.TitlePacker;
import com.fr.general.cardtag.DefaultTemplateStyle; import com.fr.general.cardtag.DefaultTemplateStyle;
import com.fr.general.cardtag.TemplateStyle; import com.fr.general.cardtag.TemplateStyle;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
@ -165,7 +166,7 @@ public class XWCardLayout extends XLayoutContainer {
WCardMainBorderLayout border = new WCardMainBorderLayout(); WCardMainBorderLayout border = new WCardMainBorderLayout();
XWCardMainBorderLayout xMainBorder = new XWCardMainBorderLayout(border, dimension); XWCardMainBorderLayout xMainBorder = new XWCardMainBorderLayout(border, dimension);
//将子WCardBorder的style设置到父容器上 //将子WCardBorder的style设置到父容器上
LayoutBorderStyle style = (this.toData()).getBorderStyle(); BorderPacker style = (this.toData()).getBorderStyle();
border.setBorderStyle(style); border.setBorderStyle(style);
this.setBackupParent(xMainBorder); this.setBackupParent(xMainBorder);
XWCardTitleLayout titlePart = this.initTitlePart(widgetName, xMainBorder); XWCardTitleLayout titlePart = this.initTitlePart(widgetName, xMainBorder);
@ -397,13 +398,13 @@ public class XWCardLayout extends XLayoutContainer {
//初始化样式 //初始化样式
@Override @Override
protected void initStyle() { protected void initStyle() {
LayoutBorderStyle style = toData().getBorderStyle(); BorderPacker style = toData().getBorderStyle();
initBorderTitleStyle(style); initBorderTitleStyle(style);
initBorderStyle(); initBorderStyle();
clearOrShowTitleLayout(ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)); clearOrShowTitleLayout(ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE));
} }
private void initBorderTitleStyle(LayoutBorderStyle style) { private void initBorderTitleStyle(BorderPacker style) {
//初始化默认标题样式 //初始化默认标题样式
if (!initFlag) { if (!initFlag) {
return; return;
@ -411,7 +412,7 @@ public class XWCardLayout extends XLayoutContainer {
style.setType(LayoutBorderStyle.TITLE); style.setType(LayoutBorderStyle.TITLE);
style.setBorder(Constants.LINE_THIN); style.setBorder(Constants.LINE_THIN);
WidgetTitle widgetTitle = style.getTitle(); TitlePacker widgetTitle = style.getTitle();
widgetTitle.setBackground(ColorBackground.getInstance(TITLE_COLOR)); widgetTitle.setBackground(ColorBackground.getInstance(TITLE_COLOR));
initFlag = false; initFlag = false;
} }

3
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -38,6 +38,7 @@ import com.fr.form.ui.container.cardlayout.WCardTitleLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.act.BorderPacker;
import com.fr.share.ShareConstants; import com.fr.share.ShareConstants;
import com.fr.stable.Constants; import com.fr.stable.Constants;
@ -164,7 +165,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
String tabpaneName = cardLayout.getWidgetName(); String tabpaneName = cardLayout.getWidgetName();
if (!wCardTagLayout.isNewTab()) { if (!wCardTagLayout.isNewTab()) {
wCardTagLayout.setWidgetName(tabpaneName); wCardTagLayout.setWidgetName(tabpaneName);
LayoutBorderStyle borderStyle = cardLayout.getBorderStyle(); BorderPacker borderStyle = cardLayout.getBorderStyle();
if(borderStyle != null){ if(borderStyle != null){
//新tab默认都有标题 //新tab默认都有标题
borderStyle.setType(LayoutBorderStyle.TITLE); borderStyle.setType(LayoutBorderStyle.TITLE);

12
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java

@ -27,21 +27,18 @@ import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetTitle;
import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.WTabDisplayPosition;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.act.BorderPacker;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.cardtag.DefaultTemplateStyle; import com.fr.general.cardtag.DefaultTemplateStyle;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.Dimension; import java.awt.*;
import java.awt.FontMetrics;
import java.awt.Rectangle;
import java.awt.event.ContainerEvent; import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.HashMap; import java.util.HashMap;
@ -363,9 +360,8 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
if (this.cardLayout == null) { if (this.cardLayout == null) {
initCardLayout(); initCardLayout();
} }
LayoutBorderStyle borderStyle = this.cardLayout.toData().getBorderStyle(); BorderPacker borderStyle = this.cardLayout.toData().getBorderStyle();
WidgetTitle title = borderStyle.getTitle(); FRFont f = borderStyle.getTitle().getFrFont();
FRFont f = title.getFrFont();
FontMetrics fm = GraphHelper.getFontMetrics(f); FontMetrics fm = GraphHelper.getFontMetrics(f);
switch (wCardTagLayout.getTextDirection()) { switch (wCardTagLayout.getTextDirection()) {

31
designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPane.java

@ -38,32 +38,17 @@ import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.WidgetTitle;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.act.TitlePacker;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import javax.swing.AbstractButton; import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.plaf.basic.BasicToggleButtonUI; import javax.swing.plaf.basic.BasicToggleButtonUI;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
@ -546,7 +531,7 @@ public class LayoutBorderPane extends BasicPane {
style.setColor(currentLineColorPane.getColor()); style.setColor(currentLineColorPane.getColor());
style.setBackground(backgroundPane.update()); style.setBackground(backgroundPane.update());
style.setAlpha((float)(numberDragPane.updateBean()/maxNumber)); style.setAlpha((float)(numberDragPane.updateBean()/maxNumber));
WidgetTitle title = style.getTitle() == null ? new WidgetTitle() : style.getTitle(); TitlePacker title = style.getTitle() == null ? new WidgetTitle() : style.getTitle();
title.setTextObject(formulaPane.updateBean()); title.setTextObject(formulaPane.updateBean());
FRFont frFont = title.getFrFont(); FRFont frFont = title.getFrFont();
frFont = frFont.applySize((Integer)fontSizeComboBox.getSelectedItem()); frFont = frFont.applySize((Integer)fontSizeComboBox.getSelectedItem());
@ -644,10 +629,10 @@ public class LayoutBorderPane extends BasicPane {
} }
protected void populateTitle(){ protected void populateTitle(){
WidgetTitle widgetTitle = borderStyle == null ? new WidgetTitle() : borderStyle.getTitle(); TitlePacker widgetTitle = borderStyle == null ? new WidgetTitle() : borderStyle.getTitle();
widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle; widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle;
populateFourmula(widgetTitle); populateFormula(widgetTitle);
populateFont(widgetTitle); populateFont(widgetTitle);
underline.addMouseListener(new MouseAdapter() { underline.addMouseListener(new MouseAdapter() {
@ -683,7 +668,7 @@ public class LayoutBorderPane extends BasicPane {
paintPreviewPane(); paintPreviewPane();
} }
protected void populateFont(WidgetTitle widgetTitle){ protected void populateFont(TitlePacker widgetTitle){
FRFont frFont = widgetTitle.getFrFont(); FRFont frFont = widgetTitle.getFrFont();
this.fontSizeComboBox.setSelectedItem(frFont.getSize()); this.fontSizeComboBox.setSelectedItem(frFont.getSize());
this.fontSizeComboBox.addItemListener(new ItemListener() { this.fontSizeComboBox.addItemListener(new ItemListener() {
@ -756,7 +741,7 @@ public class LayoutBorderPane extends BasicPane {
} }
private void populateFourmula(WidgetTitle widgetTitle) { private void populateFormula(TitlePacker widgetTitle) {
this.formulaPane.populateBean(widgetTitle.getTextObject().toString()); this.formulaPane.populateBean(widgetTitle.getTextObject().toString());
this.formulaPane.getUITextField().getDocument() this.formulaPane.getUITextField().getDocument()
.addDocumentListener(new DocumentListener() { .addDocumentListener(new DocumentListener() {

6
designer-form/src/main/java/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java

@ -7,10 +7,10 @@ import com.fr.base.background.ColorBackground;
import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; import com.fr.design.designer.creator.cardlayout.XCardSwitchButton;
import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextarea.UITextArea;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.act.TitlePacker;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -126,7 +126,7 @@ public class LayoutBorderPreviewPane extends JPanel{
g2d.setColor(new Color(237, 237, 237)); g2d.setColor(new Color(237, 237, 237));
} }
g2d.setFont(frFont.applyResolutionNP(resolution)); g2d.setFont(frFont.applyResolutionNP(resolution));
WidgetTitle title = borderStyle.getTitle(); TitlePacker title = borderStyle.getTitle();
String paintText = title.getTextObject().toString(); String paintText = title.getTextObject().toString();
int startX1 = 0; int startX1 = 0;
int startY = 0; int startY = 0;
@ -158,7 +158,7 @@ public class LayoutBorderPreviewPane extends JPanel{
GraphHelper.draw(g,double2, borderStyle.getBorder()); GraphHelper.draw(g,double2, borderStyle.getBorder());
} }
private void drawTabBack(Graphics2D g2d, Graphics g, WidgetTitle title, FontMetrics fm, int startX1, int startY){ private void drawTabBack(Graphics2D g2d, Graphics g, TitlePacker title, FontMetrics fm, int startX1, int startY){
Dimension d = getSize(); Dimension d = getSize();
String paintText = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Title")+TAB_ZERO; String paintText = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Title")+TAB_ZERO;

4
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java

@ -107,7 +107,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
public void populateBean(WCardTagLayout ob) { public void populateBean(WCardTagLayout ob) {
//标题背景和字体属性设置在WCardLayout上做兼容 //标题背景和字体属性设置在WCardLayout上做兼容
XLayoutContainer topLayout = creator.getTopLayout(); XLayoutContainer topLayout = creator.getTopLayout();
LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout) topLayout).getCardPart().toData().getBorderStyle(); LayoutBorderStyle layoutBorderStyle = (LayoutBorderStyle) ((XWCardMainBorderLayout) topLayout).getCardPart().toData().getBorderStyle();
displayPositionGroup.setSelectedIndex(ob.getDisplayPosition().getType()); displayPositionGroup.setSelectedIndex(ob.getDisplayPosition().getType());
textDirectionGroup.setSelectedIndex(ob.getTextDirection().getType()); textDirectionGroup.setSelectedIndex(ob.getTextDirection().getType());
@ -125,7 +125,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
//标题背景和字体属性设置在WCardLayout上做兼容 //标题背景和字体属性设置在WCardLayout上做兼容
XLayoutContainer topLayout = creator.getTopLayout(); XLayoutContainer topLayout = creator.getTopLayout();
XWCardLayout xCardLayout = ((XWCardMainBorderLayout) topLayout).getCardPart(); XWCardLayout xCardLayout = ((XWCardMainBorderLayout) topLayout).getCardPart();
LayoutBorderStyle layoutBorderStyle = xCardLayout.toData().getBorderStyle(); LayoutBorderStyle layoutBorderStyle = (LayoutBorderStyle) xCardLayout.toData().getBorderStyle();
FRFont frFont = layoutBorderStyle.getTitle().getFrFont() == null ? FRFont.getInstance() : layoutBorderStyle.getTitle().getFrFont(); FRFont frFont = layoutBorderStyle.getTitle().getFrFont() == null ? FRFont.getInstance() : layoutBorderStyle.getTitle().getFrFont();
FRFont titleFont = frFontPane.update(frFont); FRFont titleFont = frFontPane.update(frFont);
layoutBorderStyle.getTitle().setFrFont(titleFont); layoutBorderStyle.getTitle().setFrFont(titleFont);

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

@ -54,7 +54,6 @@ 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 {
@ -83,7 +82,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
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();
@ -93,7 +92,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
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;
} }
@ -119,13 +118,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;
} }
@ -138,7 +137,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
} }
private JSONObject getJSONContentAsByte(){ private JSONObject getJSONContentAsByte() {
JSONObject content = new JSONObject(); JSONObject content = new JSONObject();
JSONArray startStopArray = new JSONArray(); JSONArray startStopArray = new JSONArray();
@ -159,7 +158,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
return content; return content;
} }
private void sendUserInfo(){ private void sendUserInfo() {
long currentTime = new Date().getTime(); long currentTime = new Date().getTime();
long lastTime = getLastTimeMillis(); long lastTime = getLastTimeMillis();
@ -178,7 +177,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
if (success){ if (success) {
this.reset(); this.reset();
} }
} }
@ -186,13 +185,13 @@ 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;
} }
@ -212,16 +211,16 @@ public class InformationCollector implements XMLReadable, XMLWriter {
/** /**
* 收集结束使用时间 * 收集结束使用时间
*/ */
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();
} }
@ -235,7 +234,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
*/ */
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();
@ -243,7 +242,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
String fileContent = new String(out.toByteArray(), EncodeConstants.ENCODING_UTF_8); String fileContent = new String(out.toByteArray(), EncodeConstants.ENCODING_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);
} }
} }
@ -252,26 +251,16 @@ public class InformationCollector implements XMLReadable, XMLWriter {
/** /**
* 将文件内容写到输出流中 * 将文件内容写到输出流中
*/ */
private static void writeEncodeContentToFile(String fileContent, File file){ private static void writeEncodeContentToFile(String fileContent, File file) {
BufferedWriter bw = null; try (FileOutputStream fos = new FileOutputStream(file);
try {
FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos, EncodeConstants.ENCODING_UTF_8); OutputStreamWriter osw = new OutputStreamWriter(fos, EncodeConstants.ENCODING_UTF_8);
bw = new BufferedWriter(osw); BufferedWriter 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 {
if(bw != null){
try {
bw.close();
} catch (IOException e) {
}
} }
} }
}
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
startStop.add(current); startStop.add(current);
@ -284,7 +273,7 @@ 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 (int i = 0; i < startStop.size(); i++) {
@ -293,7 +282,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
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;
} }
@ -309,20 +298,20 @@ public class InformationCollector implements XMLReadable, XMLWriter {
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() {

5
designer-sdk/pom.xml

@ -17,10 +17,5 @@
<artifactId>designer-realize</artifactId> <artifactId>designer-realize</artifactId>
<version>10.0</version> <version>10.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.fr.report</groupId>
<artifactId>sdk-base</artifactId>
<version>10.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

80
designer-sdk/src/main/java/com/fr/sdk/designer/FineDesignUtils.java

@ -1,80 +0,0 @@
package com.fr.sdk.designer;
import com.fr.config.activator.ConfigurationActivator;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.log.FineLoggerFactory;
import com.fr.module.Activator;
import com.fr.module.Module;
import com.fr.module.tool.ActivatorToolBox;
import com.fr.report.ReportActivator;
import com.fr.report.RestrictionActivator;
import com.fr.report.module.ReportBaseActivator;
import com.fr.scheduler.SchedulerActivator;
import com.fr.sdk.server.shell.ModuleShell;
import com.fr.serialization.SerializationActivator;
import com.fr.stable.StringUtils;
import com.fr.startup.WorkspaceRegister;
import com.fr.store.StateServerActivator;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.WorkspaceActivator;
import com.fr.workspace.server.ServerWorkspaceRegister;
/**
* 设计器SDK模块工具类用来放一些设计器相关插件开发过程中常用的工具函数
*/
public class FineDesignUtils {
/**
* 创建一个连接远程服务器的模块
* @param remoteUrl 远程服务器地址
* @param username 用户名
* @param password 密码
* @return 模块代理对象 使用ModuleShell的start和stop控制模块启停
*/
public static ModuleShell createRemoteServerModule(String remoteUrl, String username, String password) {
return createRemoteServerModule(remoteUrl, username, password, StringUtils.EMPTY, StringUtils.EMPTY);
}
/**
* 创建一个连接远程服务器的模块
* @param remoteUrl 远程服务器地址
* @param username 用户名
* @param password 密码
* @param certPath https证书路径
* @param certSecretKey 证书秘钥
* @return 模块代理对象 使用ModuleShell的start和stop控制模块启停
*/
public static ModuleShell createRemoteServerModule(final String remoteUrl, final String username, final String password, final String certPath, final String certSecretKey) {
Module module = ActivatorToolBox.simpleLink(
new WorkspaceActivator(),
new SerializationActivator(),
new Activator() {
@Override
public void start() {
WorkspaceConnectionInfo connectionInfo = new WorkspaceConnectionInfo(remoteUrl, username, password, certPath, certSecretKey);
try {
WorkContext.switchTo(DesignerWorkspaceGenerator.generate(RemoteDesignerWorkspaceInfo.create(connectionInfo)));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(),e);
}
}
@Override
public void stop() {
}
},
new ConfigurationActivator(),
new StateServerActivator(),
new SchedulerActivator(),
new ReportBaseActivator(),
new RestrictionActivator(),
new ReportActivator(),
new WorkspaceRegister(),
new ServerWorkspaceRegister()
);
return new ModuleShell(module);
}
}

7
designer-sdk/src/test/java/com/fr/sdk/FineDesignUtilsTest.java

@ -1,7 +0,0 @@
package com.fr.sdk;
import junit.framework.TestCase;
public class FineDesignUtilsTest extends TestCase {
}
Loading…
Cancel
Save