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. 5
      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. 24
      designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java
  4. 41
      designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java
  5. 11
      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. 45
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  15. 12
      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. 15
      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. 167
      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

5
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.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
@ -263,7 +264,9 @@ abstract class UIControlPane extends JControlPane {
@Override
public void windowLostFocus(WindowEvent e) {
//在Linux上拉回焦点,不然导致一些面板关不掉
requestFocus();
if(OperatingSystem.isLinux()) {
requestFocus();
}
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 JPanel currentPane = null;
protected BackgroundQuickPane currentPane = null;
public BackgroundPane() {
@ -43,7 +43,6 @@ public class BackgroundPane extends AbstractBasicStylePane {
this.setLayout(new BorderLayout(0, 6));
typeComboBox = new UIComboBox();
final CardLayout cardlayout = new CardLayout();
// this.add(typeComboBox, BorderLayout.NORTH);
paneList = supportKindsOfBackgroundUI();
@ -58,12 +57,12 @@ public class BackgroundPane extends AbstractBasicStylePane {
typeComboBox.addItem(pane.title4PopupWindow());
centerPane.add(pane, pane.title4PopupWindow());
}
// this.add(centerPane, BorderLayout.CENTER);
typeComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
cardlayout.show(centerPane, (String) typeComboBox.getSelectedItem());
currentPane = paneList[typeComboBox.getSelectedIndex()];
fireStateChanged();
}
});

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

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

@ -144,30 +144,33 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
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;
@Override
public DBManipulationPane createDBManipulationPane() {
JTemplate jTemplate = DesignerContext.getDesignerFrame().getSelectedJTemplate();
return jTemplate == null ? new DBManipulationPane() : jTemplate.createDBManipulationPane();
}
@Override
public DBManipulationPane createDBManipulationPane() {
JTemplate jTemplate = DesignerContext.getDesignerFrame().getSelectedJTemplate();
return jTemplate == null ? new DBManipulationPane() : jTemplate.createDBManipulationPane();
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Callback_Function");
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Callback_Function");
}
@Override
public boolean isForm() {
return false;
}
@Override
public boolean isForm() {
return false;
}
public String[] getDefaultArgs() {
return new String[0];
}
};
@Override
public String[] getDefaultArgs() {
return new String[0];
}
};
}
/**
* 生成界面默认的组建

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

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

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.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.general.Background;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
/**
* @author zhou
* @since 2012-5-29下午1:12:28
*/
public abstract class BackgroundQuickPane extends BasicBeanPane<Background> implements UIObserver {
private boolean backgroundChange;
public abstract boolean accept(Background background);
@Override
@ -23,6 +29,10 @@ public abstract class BackgroundQuickPane extends BasicBeanPane<Background> impl
public abstract void reset();
public boolean isBackgroundChange() {
return backgroundChange;
}
/**
* 组件是否需要响应添加的观察者事件
*
@ -32,4 +42,20 @@ public abstract class BackgroundQuickPane extends BasicBeanPane<Background> impl
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 {
private NewColorSelectPane detailColorSelectPane;
private boolean isBackGroundColor;
public ColorBackgroundQuickPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -39,7 +38,6 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane {
public void populateColor(Color color) {
this.detailColorSelectPane.setColor(color);
isBackGroundColor = false;
}
public Color updateColor() {
@ -47,23 +45,14 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane {
return this.detailColorSelectPane.getNotNoneColor();
}
public boolean isBackGroundColor() {
return isBackGroundColor;
}
/**
* 给组件登记一个观察者监听事件
*
* @param listener 观察者监听事件
*/
@Override
public void registerChangeListener(final UIObserverListener listener) {
detailColorSelectPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
isBackGroundColor = true;
listener.doChange();
isBackGroundColor = false;
}
});
detailColorSelectPane.addChangeListener(new ChangeListenerImpl(listener));
}
@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 观察者监听事件
*/
@Override
public void registerChangeListener(final UIObserverListener listener) {
gradientBar.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
listener.doChange();
}
});
directionPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
listener.doChange();
}
});
gradientBar.addChangeListener(new ChangeListenerImpl(listener));
directionPane.addChangeListener(new ChangeListenerImpl(listener));
}
@Override

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

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

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

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

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;
}
}

45
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.stable.ArrayUtils;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
@ -177,19 +175,36 @@ public class SelectionModel {
}
private void pasteXWFitLayout() {
//自适应布局编辑器内部左上角第一个坐标点
int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1;
int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1;
//选中第一个坐标点坐在的组件
selection.setSelectedCreator((XCreator) designer.getRootComponent().getComponentAt(leftUpX, leftUpY));
Rectangle rectangle = selection.getRelativeBounds();
if (hasSelectedPasteSource()) {
selectedPaste();
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 {
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(),
clipboard,
rectangle.x + rectangle.width / 2,
rectangle.y + DELTA_X_Y);
//自适应布局编辑器内部左上角第一个坐标点
int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1;
int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1;
//选中第一个坐标点坐在的组件
selection.setSelectedCreator((XCreator) designer.getRootComponent().getComponentAt(leftUpX, leftUpY));
Rectangle rectangle = selection.getRelativeBounds();
if (hasSelectedPasteSource()) {
selectedPaste();
} else {
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(),
clipboard,
rectangle.x + rectangle.width / 2,
rectangle.y + DELTA_X_Y);
}
}
}

12
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.ComponentAdapter;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRHorizontalLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRVerticalLayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRWCardTagLayoutAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
@ -311,12 +310,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
@Override
public LayoutAdapter getLayoutAdapter() {
if (isHori()) {
return new FRHorizontalLayoutAdapter(this);
}else{
return new FRVerticalLayoutAdapter(this);
}
return new FRWCardTagLayoutAdapter(this);
}
private boolean isHori(){
@ -452,4 +446,4 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
}
}
}
}

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 新名称
*/
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);
}

15
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.stable.ArrayUtils;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
import java.awt.AlphaComposite;
import java.awt.Component;
@ -65,7 +64,7 @@ public class FormDesignerUI extends ComponentUI {
* @param c 组件
*/
@Override
public void paint(Graphics g, JComponent c) {
public void paint(final Graphics g, JComponent c) {
XCreator rootComponent = designer.getRootComponent();
this.time = (float)designer.getResolution()/ScreenResolution.getScreenResolution();
if (rootComponent != null) {
@ -101,8 +100,14 @@ public class FormDesignerUI extends ComponentUI {
if (designer.getPainter() != null) {
// ComponentAdapter和LayoutAdapter提供的额外的Painter,该Painter一般用于提示作用,
// 相当于一个浮动层, 要考虑参数面板的高度
designer.getPainter().paint(g, designer.getArea().getHorizontalValue(),
designer.getArea().getVerticalValue() + designer.getParaHeight());
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
designer.getPainter().paint(g, designer.getArea().getHorizontalValue(),
designer.getArea().getVerticalValue() + designer.getParaHeight());
return null;
}
}.execute();
}
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
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();
dbManiList.add(autoCreateDBManipulationPane());
Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.defaultJavaScriptActionPane,
Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.createDefaultJavaScriptActionPane(),
dbManiList);
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
public void setSelection(Selection selection) {
if (!ComparatorUtils.equals(this.selection, selection) ||
!ComparatorUtils.equals(EastRegionContainerPane.getInstance().getCellAttrPane(), CellElementPropertyPane.getInstance())) {
if (!ComparatorUtils.equals(this.selection, selection)
|| !ComparatorUtils.equals(EastRegionContainerPane.getInstance().getCellAttrPane(), CellElementPropertyPane.getInstance())
|| DesignModeContext.isAuthorityEditing()) {
try {
//旧选中内容编辑器释放模板对象
QuickEditor editor = this.getCurrentEditor();
@ -535,8 +536,8 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
FineLoggerFactory.getLogger().info("Nothing to release");
}
this.selection = selection;
fireSelectionChanged();
}
fireSelectionChanged();
}

167
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.stable.ArrayUtils;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.guava.base.Optional;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.base.WorkspaceConstants;
@ -36,28 +35,19 @@ public class DesignerSocketIO {
Disconnecting
}
private static Optional<Socket> socketIO = Optional.absent();
private static Socket socket = null;
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() {
if (socketIO.isPresent()) {
if (socket != null) {
status = Status.Disconnecting;
socketIO.get().close();
socketIO = Optional.absent();
socket.close();
socket = null;
}
}
@ -66,57 +56,42 @@ public class DesignerSocketIO {
if (current.isLocal()) {
return;
}
//每当更换工作环境,更新uri列表,同时更新计数器count
try {
String[] uri = getSocketUri(current);
socketIO = Optional.of(IO.socket(new URI(uri[0])));
socketIO.get().on(WorkspaceConstants.WS_LOGRECORD, printLog);
socketIO.get().on(WorkspaceConstants.CONFIG_MODIFY, new Emitter.Listener() {
@Override
public void call(Object... objects) {
assert objects != null && objects.length == 1;
String param = (String) objects[0];
EventDispatcher.fire(RemoteConfigEvent.EDIT, param);
}
});
socketIO.get().on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
@Override
public void call(Object... objects) {
/*
* todo 远程心跳断开不一定 socketio 断开 和远程紧密相关的业务都绑定在心跳上切换成心跳断开之后进行提醒
* socketio 只用推日志和通知配置变更
*/
if (status != Status.Disconnecting) {
try {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Remote_Disconnected"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
EnvChangeEntrance.getInstance().chooseEnv();
}
});
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
status = Status.Disconnected;
}
});
socketIO.get().connect();
status = Status.Connected;
uri = getSocketUri();
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
count = 0;
//建立socket并注册监听
createSocket();
}
private static void createSocket(){
//根据uri和计数器建立连接,并注册监听
try {
if(count<uri.length) {
socket = IO.socket(new URI(uri[count]));
socket.on(WorkspaceConstants.WS_LOGRECORD, printLog);
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(Workspace current) throws IOException {
private static String[] getSocketUri() throws IOException {
Workspace current = WorkContext.getCurrent();
URL url = new URL(current.getPath());
Integer[] ports = WorkContext.getCurrent().get(SocketInfoOperator.class).getPort();
WorkspaceConnection connection = WorkContext.getCurrent().getConnection();
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",
@ -130,6 +105,72 @@ public class DesignerSocketIO {
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
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);
}
}
}
};
//断开连接提醒监听器
private static final Emitter.Listener disConnectHint = new Emitter.Listener() {
@Override
public void call(Object... objects) {
/*
* todo 远程心跳断开不一定 socket 断开 和远程紧密相关的业务都绑定在心跳上切换成心跳断开之后进行提醒
* socket 只用推日志和通知配置变更
*/
if (status != Status.Disconnecting) {
try {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Remote_Disconnected"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
EnvChangeEntrance.getInstance().chooseEnv();
}
});
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
status = Status.Disconnected;
}
};
//配置变更监听器
private static final Emitter.Listener modifyConfig = new Emitter.Listener() {
@Override
public void call(Object... objects) {
assert objects != null && objects.length == 1;
String param = (String) objects[0];
EventDispatcher.fire(RemoteConfigEvent.EDIT, param);
}
};
}

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