Browse Source

Merge branch 'release/10.0' of http://cloud.finedevelop.com:2015/scm/~harrison/design into release/10.0

feature/big-screen
Harrison 5 years ago
parent
commit
3f4bcfbcb0
  1. 3
      designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java
  2. 5
      designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java
  3. 16
      designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java
  4. 5
      designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java
  5. 5
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  6. 26
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/BackgroundQuickPane.java
  7. 15
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java
  8. 13
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java
  9. 7
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java
  10. 4
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/NullBackgroundQuickPane.java
  11. 19
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java
  12. 7
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java
  13. 39
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapter.java
  14. 21
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  15. 10
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  16. 2
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java
  17. 11
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  18. 23
      designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapterTest.java
  19. 18
      designer-form/src/test/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayoutTest.java
  20. 2
      designer-realize/src/main/java/com/fr/design/expand/ParentPane.java
  21. 2
      designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java
  22. 7
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  23. 147
      designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java
  24. 60
      designer-realize/src/test/java/com/fr/design/mainframe/socketio/DesignerSocketIOTest.java

3
designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java

@ -13,6 +13,7 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor; import java.awt.Cursor;
@ -263,7 +264,9 @@ abstract class UIControlPane extends JControlPane {
@Override @Override
public void windowLostFocus(WindowEvent e) { public void windowLostFocus(WindowEvent e) {
//在Linux上拉回焦点,不然导致一些面板关不掉 //在Linux上拉回焦点,不然导致一些面板关不掉
if(OperatingSystem.isLinux()) {
requestFocus(); requestFocus();
}
hideDialog(); hideDialog();
} }
}); });

5
designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java

@ -32,7 +32,7 @@ public class BackgroundPane extends AbstractBasicStylePane {
protected BackgroundQuickPane[] paneList; protected BackgroundQuickPane[] paneList;
//获取当前面板 //获取当前面板
protected JPanel currentPane = null; protected BackgroundQuickPane currentPane = null;
public BackgroundPane() { public BackgroundPane() {
@ -43,7 +43,6 @@ public class BackgroundPane extends AbstractBasicStylePane {
this.setLayout(new BorderLayout(0, 6)); this.setLayout(new BorderLayout(0, 6));
typeComboBox = new UIComboBox(); typeComboBox = new UIComboBox();
final CardLayout cardlayout = new CardLayout(); final CardLayout cardlayout = new CardLayout();
// this.add(typeComboBox, BorderLayout.NORTH);
paneList = supportKindsOfBackgroundUI(); paneList = supportKindsOfBackgroundUI();
@ -58,12 +57,12 @@ public class BackgroundPane extends AbstractBasicStylePane {
typeComboBox.addItem(pane.title4PopupWindow()); typeComboBox.addItem(pane.title4PopupWindow());
centerPane.add(pane, pane.title4PopupWindow()); centerPane.add(pane, pane.title4PopupWindow());
} }
// this.add(centerPane, BorderLayout.CENTER);
typeComboBox.addItemListener(new ItemListener() { typeComboBox.addItemListener(new ItemListener() {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
cardlayout.show(centerPane, (String) typeComboBox.getSelectedItem()); cardlayout.show(centerPane, (String) typeComboBox.getSelectedItem());
currentPane = paneList[typeComboBox.getSelectedIndex()];
fireStateChanged(); fireStateChanged();
} }
}); });

16
designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java

@ -16,7 +16,6 @@ import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.backgroundpane.ColorBackgroundQuickPane;
import com.fr.design.style.color.NewColorSelectBox; import com.fr.design.style.color.NewColorSelectBox;
import com.fr.stable.Constants; import com.fr.stable.Constants;
@ -28,6 +27,7 @@ import javax.swing.event.ChangeListener;
import java.awt.*; import java.awt.*;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
/** /**
* @author zhou * @author zhou
@ -37,6 +37,7 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
private static final String[] BORDERARRAY = {"currentLineCombo", "currentLineColorPane", "outerToggleButton", "topToggleButton", private static final String[] BORDERARRAY = {"currentLineCombo", "currentLineColorPane", "outerToggleButton", "topToggleButton",
"leftToggleButton", "bottomToggleButton", "rightToggleButton", "innerToggleButton", "horizontalToggleButton", "verticalToggleButton"}; "leftToggleButton", "bottomToggleButton", "rightToggleButton", "innerToggleButton", "horizontalToggleButton", "verticalToggleButton"};
private static final Set<String> BORDER_SET = new HashSet<>(Arrays.asList(BORDERARRAY));
private boolean insideMode = false; private boolean insideMode = false;
private UIToggleButton topToggleButton; private UIToggleButton topToggleButton;
@ -193,26 +194,21 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse
this.verticalToggleButton.setEnabled(this.insideMode); this.verticalToggleButton.setEnabled(this.insideMode);
} }
@Override
public Style update(Style style) { public Style update(Style style) {
if (style == null) { if (style == null) {
style = Style.DEFAULT_STYLE; style = Style.DEFAULT_STYLE;
} }
CellBorderStyle cellBorderStyle = this.update(); if (backgroundPane.currentPane.isBackgroundChange()) {
HashSet<String> borderSet = new HashSet<String>(Arrays.asList(BORDERARRAY));
style = style.deriveBackground(backgroundPane.update()); style = style.deriveBackground(backgroundPane.update());
if (backgroundPane.currentPane != backgroundPane.paneList[1]){
if (borderSet.contains(globalNameListener.getGlobalName())) {
style = style.deriveBorder(cellBorderStyle.getTopStyle(), cellBorderStyle.getTopColor(), cellBorderStyle.getBottomStyle(), cellBorderStyle.getBottomColor(),
cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor(), cellBorderStyle.getRightStyle(), cellBorderStyle.getRightColor());
} }
}else { if (BORDER_SET.contains(globalNameListener.getGlobalName())) {
if (borderSet.contains(globalNameListener.getGlobalName()) && !((ColorBackgroundQuickPane) backgroundPane.currentPane).isBackGroundColor()){ CellBorderStyle cellBorderStyle = this.update();
style = style.deriveBorder(cellBorderStyle.getTopStyle(), cellBorderStyle.getTopColor(), cellBorderStyle.getBottomStyle(), cellBorderStyle.getBottomColor(), style = style.deriveBorder(cellBorderStyle.getTopStyle(), cellBorderStyle.getTopColor(), cellBorderStyle.getBottomStyle(), cellBorderStyle.getBottomColor(),
cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor(), cellBorderStyle.getRightStyle(), cellBorderStyle.getRightColor()); cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor(), cellBorderStyle.getRightStyle(), cellBorderStyle.getRightColor());
} }
}
return style; return style;
} }

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

@ -144,7 +144,8 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
return contentDBManiPane; return contentDBManiPane;
} }
public static JavaScriptActionPane defaultJavaScriptActionPane = new JavaScriptActionPane() { public static JavaScriptActionPane createDefaultJavaScriptActionPane() {
return new JavaScriptActionPane() {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -164,10 +165,12 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
return false; return false;
} }
@Override
public String[] getDefaultArgs() { public String[] getDefaultArgs() {
return new String[0]; return new String[0];
} }
}; };
}
/** /**
* 生成界面默认的组建 * 生成界面默认的组建

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

@ -458,10 +458,15 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
} }
private void refreshContainer() { private void refreshContainer() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
validate(); validate();
repaint(); repaint();
revalidate(); revalidate();
} }
});
}
public int getToolPaneY() { public int getToolPaneY() {
return 0; return 0;

26
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/BackgroundQuickPane.java

@ -2,14 +2,20 @@ package com.fr.design.mainframe.backgroundpane;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.general.Background; import com.fr.general.Background;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
/** /**
* @author zhou * @author zhou
* @since 2012-5-29下午1:12:28 * @since 2012-5-29下午1:12:28
*/ */
public abstract class BackgroundQuickPane extends BasicBeanPane<Background> implements UIObserver { public abstract class BackgroundQuickPane extends BasicBeanPane<Background> implements UIObserver {
private boolean backgroundChange;
public abstract boolean accept(Background background); public abstract boolean accept(Background background);
@Override @Override
@ -23,6 +29,10 @@ public abstract class BackgroundQuickPane extends BasicBeanPane<Background> impl
public abstract void reset(); public abstract void reset();
public boolean isBackgroundChange() {
return backgroundChange;
}
/** /**
* 组件是否需要响应添加的观察者事件 * 组件是否需要响应添加的观察者事件
* *
@ -32,4 +42,20 @@ public abstract class BackgroundQuickPane extends BasicBeanPane<Background> impl
return true; return true;
} }
class ChangeListenerImpl implements ChangeListener {
private UIObserverListener listener;
public ChangeListenerImpl(UIObserverListener listener) {
this.listener = listener;
}
@Override
public void stateChanged(ChangeEvent e) {
backgroundChange = true;
this.listener.doChange();
backgroundChange = false;
}
}
} }

15
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java

@ -19,7 +19,6 @@ import java.awt.Color;
public class ColorBackgroundQuickPane extends BackgroundQuickPane { public class ColorBackgroundQuickPane extends BackgroundQuickPane {
private NewColorSelectPane detailColorSelectPane; private NewColorSelectPane detailColorSelectPane;
private boolean isBackGroundColor;
public ColorBackgroundQuickPane() { public ColorBackgroundQuickPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -39,7 +38,6 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane {
public void populateColor(Color color) { public void populateColor(Color color) {
this.detailColorSelectPane.setColor(color); this.detailColorSelectPane.setColor(color);
isBackGroundColor = false;
} }
public Color updateColor() { public Color updateColor() {
@ -47,23 +45,14 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane {
return this.detailColorSelectPane.getNotNoneColor(); return this.detailColorSelectPane.getNotNoneColor();
} }
public boolean isBackGroundColor() {
return isBackGroundColor;
}
/** /**
* 给组件登记一个观察者监听事件 * 给组件登记一个观察者监听事件
* *
* @param listener 观察者监听事件 * @param listener 观察者监听事件
*/ */
@Override
public void registerChangeListener(final UIObserverListener listener) { public void registerChangeListener(final UIObserverListener listener) {
detailColorSelectPane.addChangeListener(new ChangeListener() { detailColorSelectPane.addChangeListener(new ChangeListenerImpl(listener));
public void stateChanged(ChangeEvent e) {
isBackGroundColor = true;
listener.doChange();
isBackGroundColor = false;
}
});
} }
@Override @Override

13
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java

@ -96,17 +96,10 @@ public class GradientBackgroundQuickPane extends BackgroundQuickPane {
* *
* @param listener 观察者监听事件 * @param listener 观察者监听事件
*/ */
@Override
public void registerChangeListener(final UIObserverListener listener) { public void registerChangeListener(final UIObserverListener listener) {
gradientBar.addChangeListener(new ChangeListener() { gradientBar.addChangeListener(new ChangeListenerImpl(listener));
public void stateChanged(ChangeEvent e) { directionPane.addChangeListener(new ChangeListenerImpl(listener));
listener.doChange();
}
});
directionPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
listener.doChange();
}
});
} }
@Override @Override

7
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java

@ -127,12 +127,7 @@ public class ImageBackgroundQuickPane extends BackgroundQuickPane {
*/ */
@Override @Override
public void registerChangeListener(final UIObserverListener listener) { public void registerChangeListener(final UIObserverListener listener) {
changeListener = new ChangeListener() { changeListener = new ChangeListenerImpl(listener);
@Override
public void stateChanged(ChangeEvent e) {
listener.doChange();
}
};
imageLayoutPane.addChangeListener(changeListener); imageLayoutPane.addChangeListener(changeListener);
} }

4
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/NullBackgroundQuickPane.java

@ -33,6 +33,10 @@ public class NullBackgroundQuickPane extends BackgroundQuickPane {
} }
@Override
public boolean isBackgroundChange() {
return true;
}
/** /**
* 是否接受 * 是否接受

19
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java

@ -112,23 +112,12 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
* *
* @param listener 观察者监听事件 * @param listener 观察者监听事件
*/ */
@Override
public void registerChangeListener(final UIObserverListener listener) { public void registerChangeListener(final UIObserverListener listener) {
foregroundColorPane.addSelectChangeListener(new ChangeListener() { foregroundColorPane.addSelectChangeListener(new ChangeListenerImpl(listener));
public void stateChanged(ChangeEvent e) { backgroundColorPane.addSelectChangeListener(new ChangeListenerImpl(listener));
listener.doChange();
}
});
backgroundColorPane.addSelectChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
listener.doChange();
}
});
for (int i = 0, count = patternButtonArray.length; i < count; i++) { for (int i = 0, count = patternButtonArray.length; i < count; i++) {
patternButtonArray[i].addChangeListener(new ChangeListener() { patternButtonArray[i].addChangeListener(new ChangeListenerImpl(listener));
public void stateChanged(ChangeEvent e) {
listener.doChange();
}
});
} }
} }

7
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java

@ -68,13 +68,10 @@ public class TextureBackgroundQuickPane extends BackgroundQuickPane {
* *
* @param listener 观察者监听事件 * @param listener 观察者监听事件
*/ */
@Override
public void registerChangeListener(final UIObserverListener listener) { public void registerChangeListener(final UIObserverListener listener) {
for (int i = 0, count = textureButtonArray.length; i < count; i++) { for (int i = 0, count = textureButtonArray.length; i < count; i++) {
textureButtonArray[i].addChangeListener(new ChangeListener() { textureButtonArray[i].addChangeListener(new ChangeListenerImpl(listener));
public void stateChanged(ChangeEvent e) {
listener.doChange();
}
});
} }
} }

39
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapter.java

@ -0,0 +1,39 @@
package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
/**
* 针对tabpane的布局适配器
* Created by kerry on 2019-12-10
*/
public class FRWCardTagLayoutAdapter extends AbstractLayoutAdapter {
public FRWCardTagLayoutAdapter(XLayoutContainer container) {
super(container);
}
/**
* 对于这种布局方式不允许其他组件添加
*
* @param creator
* @param x
* @param y
*/
@Override
protected void addComp(XCreator creator, int x, int y) {
}
/**
* 对于这种布局方式不允许其他组件添加
*
* @param creator 组件
* @param x 添加的位置x该位置是相对于container的
* @param y 添加的位置y该位置是相对于container的
* @return
*/
@Override
public boolean accept(XCreator creator, int x, int y) {
return false;
}
}

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

@ -18,9 +18,7 @@ import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import java.awt.LayoutManager; import java.awt.*;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
@ -177,6 +175,22 @@ public class SelectionModel {
} }
private void pasteXWFitLayout() { private void pasteXWFitLayout() {
if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) {
XLayoutContainer container = (XLayoutContainer) selection.getSelectedCreator();
//tab布局编辑器内部左上角第一个坐标点
int leftUpX = container.toData().getMargin().getLeft() + 1;
int leftUpY = container.toData().getMargin().getTop() + 1;
//选中第一个坐标点坐在的组件
selection.setSelectedCreator((XCreator) container.getComponentAt(leftUpX, leftUpY));
Rectangle rectangle = selection.getRelativeBounds();
if (hasSelectedPasteSource()) {
selectedPaste();
} else {
FormSelectionUtils.paste2Container(designer, container, clipboard,
rectangle.x + rectangle.width / 2,
rectangle.y + DELTA_X_Y);
}
} else {
//自适应布局编辑器内部左上角第一个坐标点 //自适应布局编辑器内部左上角第一个坐标点
int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1; int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1;
int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1; int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1;
@ -192,6 +206,7 @@ public class SelectionModel {
rectangle.y + DELTA_X_Y); rectangle.y + DELTA_X_Y);
} }
} }
}
/** /**
* 粘贴时选择组件 * 粘贴时选择组件

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

@ -8,8 +8,7 @@ import com.fr.base.ScreenResolution;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRHorizontalLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRWCardTagLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRVerticalLayoutAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
@ -311,12 +310,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
@Override @Override
public LayoutAdapter getLayoutAdapter() { public LayoutAdapter getLayoutAdapter() {
if (isHori()) { return new FRWCardTagLayoutAdapter(this);
return new FRHorizontalLayoutAdapter(this);
}else{
return new FRVerticalLayoutAdapter(this);
}
} }
private boolean isHori(){ private boolean isHori(){

2
designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java

@ -212,7 +212,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
* @param newName 新名称 * @param newName 新名称
*/ */
public void refresh4TableData(String oldName, String newName) { public void refresh4TableData(String oldName, String newName) {
this.getTarget().renameTableData(oldName, newName); this.getTarget().renameTableData(this.getTarget().getContainer(), oldName, newName);
this.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_SELECTED); this.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_SELECTED);
} }

11
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

@ -23,8 +23,7 @@ import com.fr.page.WatermarkPainter;
import com.fr.report.core.ReportUtils; import com.fr.report.core.ReportUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import javax.swing.JComponent; import javax.swing.*;
import javax.swing.SwingUtilities;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.Component; import java.awt.Component;
@ -65,7 +64,7 @@ public class FormDesignerUI extends ComponentUI {
* @param c 组件 * @param c 组件
*/ */
@Override @Override
public void paint(Graphics g, JComponent c) { public void paint(final Graphics g, JComponent c) {
XCreator rootComponent = designer.getRootComponent(); XCreator rootComponent = designer.getRootComponent();
this.time = (float)designer.getResolution()/ScreenResolution.getScreenResolution(); this.time = (float)designer.getResolution()/ScreenResolution.getScreenResolution();
if (rootComponent != null) { if (rootComponent != null) {
@ -101,8 +100,14 @@ public class FormDesignerUI extends ComponentUI {
if (designer.getPainter() != null) { if (designer.getPainter() != null) {
// ComponentAdapter和LayoutAdapter提供的额外的Painter,该Painter一般用于提示作用, // ComponentAdapter和LayoutAdapter提供的额外的Painter,该Painter一般用于提示作用,
// 相当于一个浮动层, 要考虑参数面板的高度 // 相当于一个浮动层, 要考虑参数面板的高度
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
designer.getPainter().paint(g, designer.getArea().getHorizontalValue(), designer.getPainter().paint(g, designer.getArea().getHorizontalValue(),
designer.getArea().getVerticalValue() + designer.getParaHeight()); designer.getArea().getVerticalValue() + designer.getParaHeight());
return null;
}
}.execute();
} }
AddingModel addingModel = designer.getAddingModel(); AddingModel addingModel = designer.getAddingModel();

23
designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapterTest.java

@ -0,0 +1,23 @@
package com.fr.design.designer.beans.adapters.layout;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import org.junit.Assert;
import org.junit.Test;
import java.awt.Dimension;
/**
* Created by kerry on 2019-12-10
*/
public class FRWCardTagLayoutAdapterTest {
@Test
public void testAccept() {
FRWCardTagLayoutAdapter adapter = new FRWCardTagLayoutAdapter(
new XWCardTagLayout(new WCardTagLayout(), new Dimension(100, 100)));
Assert.assertFalse(adapter.accept(new XElementCase(
new ElementCaseEditor(), new Dimension(100, 100)), 1, 1));
}
}

18
designer-form/src/test/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayoutTest.java

@ -0,0 +1,18 @@
package com.fr.design.designer.creator.cardlayout;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import org.junit.Assert;
import org.junit.Test;
import java.awt.Dimension;
/**
* Created by kerry on 2019-12-10
*/
public class XWCardTagLayoutTest {
@Test
public void testGetLayoutAdapter() {
XWCardTagLayout tagLayout = new XWCardTagLayout(new WCardTagLayout(), new Dimension(100, 100));
Assert.assertEquals("com.fr.design.designer.beans.adapters.layout.FRWCardTagLayoutAdapter", tagLayout.getLayoutAdapter().getClass().getName());
}
}

2
designer-realize/src/main/java/com/fr/design/expand/ParentPane.java

@ -195,7 +195,7 @@ public class ParentPane extends BasicPane {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
cardLayout.show(parentCardPane, "Fine-Design_Report_Default"); cardLayout.show(parentCardPane, "Default");
} }
}); });

2
designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java

@ -81,7 +81,7 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
// 提交入库 // 提交入库
List dbManiList = new ArrayList(); List dbManiList = new ArrayList();
dbManiList.add(autoCreateDBManipulationPane()); dbManiList.add(autoCreateDBManipulationPane());
Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.defaultJavaScriptActionPane, Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.createDefaultJavaScriptActionPane(),
dbManiList); dbManiList);
hyperlinkPane.add(DBCOMMIT, commit2DBJavaScriptPane); hyperlinkPane.add(DBCOMMIT, commit2DBJavaScriptPane);
// 自定义事件 // 自定义事件

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

@ -523,8 +523,9 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
@Override @Override
public void setSelection(Selection selection) { public void setSelection(Selection selection) {
if (!ComparatorUtils.equals(this.selection, selection) || if (!ComparatorUtils.equals(this.selection, selection)
!ComparatorUtils.equals(EastRegionContainerPane.getInstance().getCellAttrPane(), CellElementPropertyPane.getInstance())) { || !ComparatorUtils.equals(EastRegionContainerPane.getInstance().getCellAttrPane(), CellElementPropertyPane.getInstance())
|| DesignModeContext.isAuthorityEditing()) {
try { try {
//旧选中内容编辑器释放模板对象 //旧选中内容编辑器释放模板对象
QuickEditor editor = this.getCurrentEditor(); QuickEditor editor = this.getCurrentEditor();
@ -535,9 +536,9 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
FineLoggerFactory.getLogger().info("Nothing to release"); FineLoggerFactory.getLogger().info("Nothing to release");
} }
this.selection = selection; this.selection = selection;
}
fireSelectionChanged(); fireSelectionChanged();
} }
}
public void setOldSelecton(Selection selection) { public void setOldSelecton(Selection selection) {

147
designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java

@ -13,7 +13,6 @@ import com.fr.report.RemoteDesignConstants;
import com.fr.serialization.SerializerHelper; import com.fr.serialization.SerializerHelper;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.guava.base.Optional;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.base.WorkspaceConstants; import com.fr.workspace.base.WorkspaceConstants;
@ -36,28 +35,19 @@ public class DesignerSocketIO {
Disconnecting Disconnecting
} }
private static Optional<Socket> socketIO = Optional.absent(); private static Socket socket = null;
private static Status status = Status.Disconnected; private static Status status = Status.Disconnected;
//维护一个当前工作环境的uri列表
private static String[] uri;
//维护一个关于uri列表的计数器
private static int count;
private static final Emitter.Listener printLog = new Emitter.Listener() {
@Override
public void call(Object... objects) {
if (ArrayUtils.isNotEmpty(objects)) {
try {
LoggingEvent event = SerializerHelper.deserialize((byte[]) objects[0]);
DesignerLogger.log(event);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
};
public static void close() { public static void close() {
if (socketIO.isPresent()) { if (socket != null) {
status = Status.Disconnecting; status = Status.Disconnecting;
socketIO.get().close(); socket.close();
socketIO = Optional.absent(); socket = null;
} }
} }
@ -66,24 +56,90 @@ public class DesignerSocketIO {
if (current.isLocal()) { if (current.isLocal()) {
return; return;
} }
//每当更换工作环境,更新uri列表,同时更新计数器count
try {
uri = getSocketUri();
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
count = 0;
//建立socket并注册监听
createSocket();
}
private static void createSocket(){
//根据uri和计数器建立连接,并注册监听
try { try {
String[] uri = getSocketUri(current); if(count<uri.length) {
socketIO = Optional.of(IO.socket(new URI(uri[0]))); socket = IO.socket(new URI(uri[count]));
socketIO.get().on(WorkspaceConstants.WS_LOGRECORD, printLog); socket.on(WorkspaceConstants.WS_LOGRECORD, printLog);
socketIO.get().on(WorkspaceConstants.CONFIG_MODIFY, new Emitter.Listener() { socket.on(WorkspaceConstants.CONFIG_MODIFY, modifyConfig);
socket.on(Socket.EVENT_CONNECT_ERROR, failRetry);
socket.on(Socket.EVENT_DISCONNECT, disConnectHint);
socket.connect();
status = Status.Connected;
}else {
//表示所有的uri都连接不成功
FineLoggerFactory.getLogger().warn("All uris failed to connect");
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private static String[] getSocketUri() throws IOException {
Workspace current = WorkContext.getCurrent();
URL url = new URL(current.getPath());
Integer[] ports = current.get(SocketInfoOperator.class).getPort();
WorkspaceConnection connection = current.getConnection();
String[] result = new String[ports.length];
for (int i = 0; i < ports.length; i++) {
result[i] = String.format("%s://%s:%s%s?%s=%s&%s=%s",
url.getProtocol(),
url.getHost(),
ports[i],
WorkspaceConstants.WS_NAMESPACE,
DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME,
connection.getToken(),
RemoteDesignConstants.USER_LOCK_ID,
connection.getId());
}
return result;
}
//失败重试监听器:1、关闭失败的socket 2、计数器加1 3、调用创建socket方法
private static final Emitter.Listener failRetry = new Emitter.Listener() {
@Override
public void call(Object... args) {
status = Status.Disconnecting;
socket.close();
count++;
createSocket();
}
};
//日志输出监听器
private static final Emitter.Listener printLog = new Emitter.Listener() {
@Override @Override
public void call(Object... objects) { public void call(Object... objects) {
assert objects != null && objects.length == 1; if (ArrayUtils.isNotEmpty(objects)) {
String param = (String) objects[0]; try {
EventDispatcher.fire(RemoteConfigEvent.EDIT, param); LoggingEvent event = SerializerHelper.deserialize((byte[]) objects[0]);
DesignerLogger.log(event);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
}); }
socketIO.get().on(Socket.EVENT_DISCONNECT, new Emitter.Listener() { }
};
//断开连接提醒监听器
private static final Emitter.Listener disConnectHint = new Emitter.Listener() {
@Override @Override
public void call(Object... objects) { public void call(Object... objects) {
/* /*
* todo 远程心跳断开不一定 socketio 断开 和远程紧密相关的业务都绑定在心跳上切换成心跳断开之后进行提醒 * todo 远程心跳断开不一定 socket 断开 和远程紧密相关的业务都绑定在心跳上切换成心跳断开之后进行提醒
* socketio 只用推日志和通知配置变更 * socket 只用推日志和通知配置变更
*/ */
if (status != Status.Disconnecting) { if (status != Status.Disconnecting) {
try { try {
@ -105,31 +161,16 @@ public class DesignerSocketIO {
} }
status = Status.Disconnected; status = Status.Disconnected;
} }
}); };
socketIO.get().connect();
status = Status.Connected;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private static String[] getSocketUri(Workspace current) throws IOException { //配置变更监听器
URL url = new URL(current.getPath()); private static final Emitter.Listener modifyConfig = new Emitter.Listener() {
Integer[] ports = WorkContext.getCurrent().get(SocketInfoOperator.class).getPort(); @Override
WorkspaceConnection connection = WorkContext.getCurrent().getConnection(); public void call(Object... objects) {
String[] result = new String[ports.length]; assert objects != null && objects.length == 1;
for (int i = 0; i < ports.length; i++) { String param = (String) objects[0];
result[i] = String.format("%s://%s:%s%s?%s=%s&%s=%s", EventDispatcher.fire(RemoteConfigEvent.EDIT, param);
url.getProtocol(),
url.getHost(),
ports[i],
WorkspaceConstants.WS_NAMESPACE,
DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME,
connection.getToken(),
RemoteDesignConstants.USER_LOCK_ID,
connection.getId());
} }
return result; };
} }
}

60
designer-realize/src/test/java/com/fr/design/mainframe/socketio/DesignerSocketIOTest.java

@ -0,0 +1,60 @@
package com.fr.design.mainframe.socketio;
import com.fr.invoke.Reflect;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import io.socket.client.IO;
import io.socket.client.Socket;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
/**
* @author: Maksim
* @Date: Created in 2019/12/9
* @Description:
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({WorkContext.class,DesignerSocketIO.class, IO.class})
public class DesignerSocketIOTest {
@Test
public void close() throws Exception {
this.update();
DesignerSocketIO.close();
DesignerSocketIO.Status status = Reflect.on(DesignerSocketIO.class).field("status").get();
Socket socket = Reflect.on(DesignerSocketIO.class).field("socket").get();
Assert.assertEquals(DesignerSocketIO.Status.Disconnecting,status);
Assert.assertNull(socket);
}
@Test
public void update() throws Exception {
Workspace current = EasyMock.mock(Workspace.class);
EasyMock.expect(current.isLocal()).andReturn(false);
PowerMock.mockStatic(WorkContext.class);
EasyMock.expect(WorkContext.getCurrent()).andReturn(current);
String[] uri = {"http://127.0.0.1:8888/workspace","http://127.0.0.1:9999/workspace"};
PowerMock.mockStaticPartial(DesignerSocketIO.class,"getSocketUri");
PowerMock.expectPrivate(DesignerSocketIO.class,"getSocketUri").andReturn(uri);
EasyMock.replay(current);
PowerMock.replayAll();
DesignerSocketIO.update();
DesignerSocketIO.Status status = Reflect.on(DesignerSocketIO.class).field("status").get();
Socket socket = Reflect.on(DesignerSocketIO.class).field("socket").get();
Assert.assertEquals(DesignerSocketIO.Status.Connected,status);
Assert.assertNotNull(socket);
}
}
Loading…
Cancel
Save