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.gui.itextfield.UINumberField;
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) {
value = Math.max(value, minValue);
value = Math.min(value, maxValue);
if (this.value == value) {
if (AssistUtils.equals(this.value, value)) {
return;
}
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.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
@ -81,7 +82,7 @@ public abstract class UnitInputPane extends BasicPane {
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:默认应该为选中,方便用户修改
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.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
@ -362,10 +363,10 @@ public class UpdateMainDialog extends UIDialog {
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(updateActionPane, BorderLayout.SOUTH);
}else {
} else {
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) {
return;
}
OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), "UTF-8");
BufferedWriter bufferWriter = new BufferedWriter(writerStream);
try (OutputStreamWriter writerStream = new OutputStreamWriter(new FileOutputStream(cacheFile), EncodeConstants.ENCODING_UTF_8);
BufferedWriter bufferWriter = new BufferedWriter(writerStream)) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jo = (JSONObject) jsonArray.get(i);
bufferWriter.write((String) jo.get("update") + '\t' + jo.get("title"));
bufferWriter.newLine();
bufferWriter.flush();
}
bufferWriter.close();
writerStream.close();
}
lastUpdateCacheState = UPDATE_CACHE_STATE_SUCCESS;
lastUpdateCacheTime = endTime;
cacheProperty.updateProperty("updateTime", lastUpdateCacheTime);
@ -634,6 +634,7 @@ public class UpdateMainDialog extends UIDialog {
/**
* 获取当前jar的md5
*
* @param currentJAR
* @return
*/

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

@ -67,8 +67,7 @@ public class DesignUtils {
* @return 启动了返回true
*/
public static boolean isStarted() {
try {
new Socket("localhost", port);
try (Socket socket = new Socket("localhost", port)) {
return true;
} catch (Exception ignored) {
}
@ -116,6 +115,7 @@ public class DesignUtils {
* @param startPort 端口
* @param suffixs 文件后缀
*/
@SuppressWarnings("squid:S2095")
public static void createListeningServer(final int startPort, final String[] suffixs) {
ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("DesignClientListener"));
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();
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
//取消下载
result = false;
exitDialog();
}
@Override
public void windowOpened(WindowEvent e) {
downloadAndInstallPluginDependenceFile();
exitDialog();
@ -119,11 +121,11 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent {
httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteInfo.siteKind));
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStream reader = httpClient.getResponseStream();
String temp = StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE);
File file = new File(temp);
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];
int bytesRead;
while ((bytesRead = reader.read(buffer)) > 0 && result) {
@ -133,11 +135,8 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent {
currentBytesRead += bytesRead;
setProgress(currentBytesRead);
}
reader.close();
writer.flush();
writer.close();
}
if (result) {
//安装文件
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.cardlayout.WCardMainBorderLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.act.BorderPacker;
import java.awt.Component;
import java.awt.Dimension;
@ -284,7 +285,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter {
backupBound.x -= rec.x;
backupBound.y -= rec.y;
XWCardLayout cardLayout = mainLayout.getCardPart();
LayoutBorderStyle style = cardLayout.toData().getBorderStyle();
BorderPacker style = cardLayout.toData().getBorderStyle();
XWCardTitleLayout xwCardTitleLayout = mainLayout.getTitlePart();
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.designer.creator.XCreator;
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.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.FRTabFitLayoutPropertiesGroupModel;
import com.fr.design.mainframe.widget.editors.ParameterEditor;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.act.BorderPacker;
import java.awt.*;
@ -90,7 +88,7 @@ public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter {
// TODO 可以直接在这边将x,y都变成相对坐标,这样在后面判断拖进来的新控件放置方式的时候就不用再判断了
private int adjustY(int y, XWTabFitLayout tabLayout) {
XWCardLayout cardLayout = (XWCardLayout) tabLayout.getBackupParent();
LayoutBorderStyle style = cardLayout.toData().getBorderStyle();
BorderPacker style = cardLayout.toData().getBorderStyle();
y = y - this.getParaEditorYOffset();
if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) {
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.container.WTitleLayout;
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.StringUtils;
@ -41,7 +43,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
}
protected void initStyle() {
LayoutBorderStyle style = toData().getBorderStyle();
BorderPacker style = toData().getBorderStyle();
initBorderStyle();
if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) {
initTitleStyle(style);
@ -52,7 +54,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
// 边框默认值设为NONE,不然像scalelayout这种只用默认边框的会不显示边框
protected void initBorderStyle() {
LayoutBorderStyle style = toData().getBorderStyle();
BorderPacker style = toData().getBorderStyle();
if (style != null && style.getBorder() != Constants.LINE_NONE) {
this.setBorder(new UIRoundedBorder(style.getBorder(), style.getColor(), style.getBorderRadius()));
} else {
@ -74,8 +76,8 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
* 设置样式为标题样式时对应组件加上标题
* @param style 样式
*/
protected void initTitleStyle(LayoutBorderStyle style){
if (style.getTitle() == null) {
protected void initTitleStyle(BorderPacker style){
if (style.getTitle() == null || style.getTitle().getTextObject() == null) {
return;
}
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.setColor(style.getColor());
// 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.setFont(wTitle.getFrFont());
title.setTextalign(wTitle.getPosition());
title.setBackground(wTitle.getBackground());
}
private WidgetValue getTitleValue(WidgetTitle wTitle){
private WidgetValue getTitleValue(TitlePacker wTitle){
String content = String.valueOf(wTitle.getTextObject());
Object vlaue = content.startsWith("=") ? BaseFormula.createFormulaBuilder().build(content) : content;
return new WidgetValue(vlaue);
Object value = content.startsWith("=") ? BaseFormula.createFormulaBuilder().build(content) : content;
return new WidgetValue(value);
}
@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.LayoutUtils;
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.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.Background;
import com.fr.general.act.BorderPacker;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.act.TitlePacker;
import com.fr.general.cardtag.TemplateStyle;
import com.fr.stable.unit.PT;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.*;
import javax.swing.plaf.basic.BasicLabelUI;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
@ -308,7 +297,7 @@ public class XCardSwitchButton extends XButton {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
CardSwitchButton button = (CardSwitchButton) this.toData();
WidgetTitle widgetTitle = getWidgetTitle();
TitlePacker widgetTitle = getWidgetTitle();
drawBackground(button, widgetTitle);
drawTitle(button, widgetTitle);
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();
TemplateStyle templateStyle = ((WCardTagLayout) tagLayout.toData()).getTemplateStyle();
//获取当前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();
this.setButtonText(titleText);
FRFont font = widgetTitle.getFrFont();
@ -351,11 +340,11 @@ public class XCardSwitchButton extends XButton {
}
private WidgetTitle getWidgetTitle() {
private TitlePacker getWidgetTitle() {
if (this.cardLayout == null) {
initRelateLayout();
}
LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle();
BorderPacker style = this.cardLayout.toData().getBorderStyle();
return style.getTitle();
}
@ -463,7 +452,7 @@ public class XCardSwitchButton extends XButton {
String titleText = button.getText();
java.util.List verticalTextList = new ArrayList();
StringBuilder titleStringBuf = new StringBuilder();
WidgetTitle title = getWidgetTitle();
TitlePacker title = getWidgetTitle();
FRFont font = title.getFrFont();
FRFont newFont = FRFont.getInstance(font.getName(), font.getStyle(), font.getSize() + FONT_SIZE_ADJUST);
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.LayoutBorderStyle;
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.WCardLayout;
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.WCardTitleLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.act.BorderPacker;
import com.fr.general.ComparatorUtils;
import com.fr.general.act.TitlePacker;
import com.fr.general.cardtag.DefaultTemplateStyle;
import com.fr.general.cardtag.TemplateStyle;
import com.fr.stable.ArrayUtils;
@ -165,7 +166,7 @@ public class XWCardLayout extends XLayoutContainer {
WCardMainBorderLayout border = new WCardMainBorderLayout();
XWCardMainBorderLayout xMainBorder = new XWCardMainBorderLayout(border, dimension);
//将子WCardBorder的style设置到父容器上
LayoutBorderStyle style = (this.toData()).getBorderStyle();
BorderPacker style = (this.toData()).getBorderStyle();
border.setBorderStyle(style);
this.setBackupParent(xMainBorder);
XWCardTitleLayout titlePart = this.initTitlePart(widgetName, xMainBorder);
@ -397,13 +398,13 @@ public class XWCardLayout extends XLayoutContainer {
//初始化样式
@Override
protected void initStyle() {
LayoutBorderStyle style = toData().getBorderStyle();
BorderPacker style = toData().getBorderStyle();
initBorderTitleStyle(style);
initBorderStyle();
clearOrShowTitleLayout(ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE));
}
private void initBorderTitleStyle(LayoutBorderStyle style) {
private void initBorderTitleStyle(BorderPacker style) {
//初始化默认标题样式
if (!initFlag) {
return;
@ -411,7 +412,7 @@ public class XWCardLayout extends XLayoutContainer {
style.setType(LayoutBorderStyle.TITLE);
style.setBorder(Constants.LINE_THIN);
WidgetTitle widgetTitle = style.getTitle();
TitlePacker widgetTitle = style.getTitle();
widgetTitle.setBackground(ColorBackground.getInstance(TITLE_COLOR));
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.IOUtils;
import com.fr.general.act.BorderPacker;
import com.fr.share.ShareConstants;
import com.fr.stable.Constants;
@ -164,7 +165,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
String tabpaneName = cardLayout.getWidgetName();
if (!wCardTagLayout.isNewTab()) {
wCardTagLayout.setWidgetName(tabpaneName);
LayoutBorderStyle borderStyle = cardLayout.getBorderStyle();
BorderPacker borderStyle = cardLayout.getBorderStyle();
if(borderStyle != null){
//新tab默认都有标题
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.WidgetPropertyPane;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.LayoutBorderStyle;
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.WTabDisplayPosition;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.act.BorderPacker;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.cardtag.DefaultTemplateStyle;
import javax.swing.border.Border;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Rectangle;
import java.awt.*;
import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent;
import java.util.HashMap;
@ -363,9 +360,8 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
if (this.cardLayout == null) {
initCardLayout();
}
LayoutBorderStyle borderStyle = this.cardLayout.toData().getBorderStyle();
WidgetTitle title = borderStyle.getTitle();
FRFont f = title.getFrFont();
BorderPacker borderStyle = this.cardLayout.toData().getBorderStyle();
FRFont f = borderStyle.getTitle().getFrFont();
FontMetrics fm = GraphHelper.getFontMetrics(f);
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.general.Background;
import com.fr.general.FRFont;
import com.fr.general.act.TitlePacker;
import com.fr.stable.Constants;
import javax.swing.AbstractButton;
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.*;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.basic.BasicToggleButtonUI;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
@ -546,7 +531,7 @@ public class LayoutBorderPane extends BasicPane {
style.setColor(currentLineColorPane.getColor());
style.setBackground(backgroundPane.update());
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());
FRFont frFont = title.getFrFont();
frFont = frFont.applySize((Integer)fontSizeComboBox.getSelectedItem());
@ -644,10 +629,10 @@ public class LayoutBorderPane extends BasicPane {
}
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;
populateFourmula(widgetTitle);
populateFormula(widgetTitle);
populateFont(widgetTitle);
underline.addMouseListener(new MouseAdapter() {
@ -683,7 +668,7 @@ public class LayoutBorderPane extends BasicPane {
paintPreviewPane();
}
protected void populateFont(WidgetTitle widgetTitle){
protected void populateFont(TitlePacker widgetTitle){
FRFont frFont = widgetTitle.getFrFont();
this.fontSizeComboBox.setSelectedItem(frFont.getSize());
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.getUITextField().getDocument()
.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.gui.itextarea.UITextArea;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle;
import com.fr.general.Background;
import com.fr.general.FRFont;
import com.fr.general.act.TitlePacker;
import com.fr.stable.Constants;
import javax.swing.JPanel;
@ -126,7 +126,7 @@ public class LayoutBorderPreviewPane extends JPanel{
g2d.setColor(new Color(237, 237, 237));
}
g2d.setFont(frFont.applyResolutionNP(resolution));
WidgetTitle title = borderStyle.getTitle();
TitlePacker title = borderStyle.getTitle();
String paintText = title.getTextObject().toString();
int startX1 = 0;
int startY = 0;
@ -158,7 +158,7 @@ public class LayoutBorderPreviewPane extends JPanel{
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();
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) {
//标题背景和字体属性设置在WCardLayout上做兼容
XLayoutContainer topLayout = creator.getTopLayout();
LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout) topLayout).getCardPart().toData().getBorderStyle();
LayoutBorderStyle layoutBorderStyle = (LayoutBorderStyle) ((XWCardMainBorderLayout) topLayout).getCardPart().toData().getBorderStyle();
displayPositionGroup.setSelectedIndex(ob.getDisplayPosition().getType());
textDirectionGroup.setSelectedIndex(ob.getTextDirection().getType());
@ -125,7 +125,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
//标题背景和字体属性设置在WCardLayout上做兼容
XLayoutContainer topLayout = creator.getTopLayout();
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 titleFont = frFontPane.update(frFont);
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
*
* @date: 2015-4-8-下午5:11:46
*/
public class InformationCollector implements XMLReadable, XMLWriter {
@ -83,7 +82,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
private String lastTime;
private StartStopTime current = new StartStopTime();
public static InformationCollector getInstance(){
public static InformationCollector getInstance() {
if (collector == null) {
collector = new InformationCollector();
@ -93,7 +92,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
return collector;
}
private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile){
private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile) {
if (xmlFile == null || !xmlFile.exists()) {
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);
String encodeContent = IOUtils.inputStream2String(encodeInputStream);
return DesUtils.getDecString(encodeContent);
}
private long getLastTimeMillis(){
private long getLastTimeMillis() {
if (StringUtils.isEmpty(this.lastTime)) {
return 0;
}
@ -138,7 +137,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
}
private JSONObject getJSONContentAsByte(){
private JSONObject getJSONContentAsByte() {
JSONObject content = new JSONObject();
JSONArray startStopArray = new JSONArray();
@ -159,7 +158,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
return content;
}
private void sendUserInfo(){
private void sendUserInfo() {
long currentTime = new Date().getTime();
long lastTime = getLastTimeMillis();
@ -178,7 +177,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (success){
if (success) {
this.reset();
}
}
@ -186,13 +185,13 @@ public class InformationCollector implements XMLReadable, XMLWriter {
/**
* 收集开始使用时间发送信息
*/
public void collectStartTime(){
public void collectStartTime() {
this.current.setStartDate(dateToString());
sendUserInfoInOtherThread();
}
private void sendUserInfoInOtherThread(){
private void sendUserInfoInOtherThread() {
if (!DesignerEnvManager.getEnvManager().isJoinProductImprove() || !FRContext.isChineseEnv()) {
return;
}
@ -212,16 +211,16 @@ public class InformationCollector implements XMLReadable, XMLWriter {
/**
* 收集结束使用时间
*/
public void collectStopTime(){
public void collectStopTime() {
this.current.setStopDate(dateToString());
}
private String dateToString(){
private String dateToString() {
DateFormat df = FRContext.getDefaultValues().getDateTimeFormat();
return df.format(new Date());
}
private void reset(){
private void reset() {
this.startStop.clear();
this.lastTime = dateToString();
}
@ -235,7 +234,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
*/
public void saveXMLFile() {
File xmlFile = this.getInfoFile();
try{
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLTools.writeOutputStreamXML(this, out);
out.flush();
@ -243,7 +242,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
String fileContent = new String(out.toByteArray(), EncodeConstants.ENCODING_UTF_8);
String encodeCotent = DesUtils.getEncString(fileContent);
writeEncodeContentToFile(encodeCotent, xmlFile);
}catch (Exception e) {
} catch (Exception 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){
BufferedWriter bw = null;
try {
FileOutputStream fos = new FileOutputStream(file);
private static void writeEncodeContentToFile(String fileContent, File file) {
try (FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fos, EncodeConstants.ENCODING_UTF_8);
bw = new BufferedWriter(osw);
BufferedWriter bw = new BufferedWriter(osw)) {
bw.write(fileContent);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
if(bw != null){
try {
bw.close();
} catch (IOException e) {
}
}
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
startStop.add(current);
@ -284,7 +273,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
writer.end();
}
private void writeStartStopList(XMLPrintWriter writer){
private void writeStartStopList(XMLPrintWriter writer) {
//启停
writer.startTAG(XML_START_STOP_LIST);
for (int i = 0; i < startStop.size(); i++) {
@ -293,7 +282,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
writer.end();
}
private void writeTag(String tag, String content, XMLPrintWriter writer){
private void writeTag(String tag, String content, XMLPrintWriter writer) {
if (StringUtils.isEmpty(content)) {
return;
}
@ -309,20 +298,20 @@ public class InformationCollector implements XMLReadable, XMLWriter {
String name = reader.getTagName();
if (XML_START_STOP_LIST.equals(name)) {
readStartStopList(reader);
} else if(XML_LAST_TIME.equals(name)){
} else if (XML_LAST_TIME.equals(name)) {
readLastTime(reader);
}
}
}
private void readLastTime(XMLableReader reader){
private void readLastTime(XMLableReader reader) {
String tmpVal;
if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) {
this.lastTime = tmpVal;
}
}
private void readStartStopList(XMLableReader reader){
private void readStartStopList(XMLableReader reader) {
startStop.clear();
reader.readXMLObject(new XMLReadable() {

5
designer-sdk/pom.xml

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