diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java index 5c6fcdab1d..28df89b80a 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java +++ b/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(); } }); diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java index 3ad75044c2..88ee482cb8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java +++ b/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(); } }); diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java index ce3940bf2a..da0cd32ed5 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java +++ b/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 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 borderSet = new HashSet(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; diff --git a/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java b/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java index ee1e1905f6..f54b070b0a 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java @@ -144,30 +144,33 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane { 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]; + } + }; + } /** * 生成界面默认的组建 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 97ce22814d..07191d536d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/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() { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/BackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/BackgroundQuickPane.java index 850132d863..99e482355c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/BackgroundQuickPane.java +++ b/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 implements UIObserver { + private boolean backgroundChange; + public abstract boolean accept(Background background); @Override @@ -23,6 +29,10 @@ public abstract class BackgroundQuickPane extends BasicBeanPane impl public abstract void reset(); + public boolean isBackgroundChange() { + return backgroundChange; + } + /** * 组件是否需要响应添加的观察者事件 * @@ -32,4 +42,20 @@ public abstract class BackgroundQuickPane extends BasicBeanPane 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; + } + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java index 89c61ec9d0..f9b4c160e5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java +++ b/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 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java index 09be6771cf..6c3ea9e727 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/GradientBackgroundQuickPane.java +++ b/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 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java index afa6fc9077..e1496ff3d6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java +++ b/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); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/NullBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/NullBackgroundQuickPane.java index 8aa6573f51..9a86a38c11 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/NullBackgroundQuickPane.java +++ b/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; + } /** * 是否接受 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java index 9da1344dcd..8f4c2ecfbf 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java +++ b/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)); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java index 0d94bf3bce..e9aed06acd 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/TextureBackgroundQuickPane.java +++ b/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)); } } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapter.java new file mode 100644 index 0000000000..e5331edd05 --- /dev/null +++ b/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; + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index 76eb602300..052ae05390 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/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); + } } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java index 77282f63f9..dc8bb90801 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java +++ b/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 { } } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java index bac50642e0..c72aa45128 100644 --- a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java +++ b/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); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index 6e8419f72f..7c2b67352c 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/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() { + @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(); diff --git a/designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapterTest.java b/designer-form/src/test/java/com/fr/design/designer/beans/adapters/layout/FRWCardTagLayoutAdapterTest.java new file mode 100644 index 0000000000..0ff3ec0cc9 --- /dev/null +++ b/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)); + } +} diff --git a/designer-form/src/test/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayoutTest.java b/designer-form/src/test/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayoutTest.java new file mode 100644 index 0000000000..2b5ec78f21 --- /dev/null +++ b/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()); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/expand/ParentPane.java b/designer-realize/src/main/java/com/fr/design/expand/ParentPane.java index e376902185..824e392e64 100644 --- a/designer-realize/src/main/java/com/fr/design/expand/ParentPane.java +++ b/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"); } }); diff --git a/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java b/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java index 5f1f941faa..b89971f879 100644 --- a/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java +++ b/designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java @@ -81,7 +81,7 @@ public class ListenerEditPane extends BasicBeanPane { // 提交入库 List dbManiList = new ArrayList(); dbManiList.add(autoCreateDBManipulationPane()); - Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.defaultJavaScriptActionPane, + Commit2DBJavaScriptPane commit2DBJavaScriptPane = new Commit2DBJavaScriptPane(JavaScriptActionPane.createDefaultJavaScriptActionPane(), dbManiList); hyperlinkPane.add(DBCOMMIT, commit2DBJavaScriptPane); // 自定义事件 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java index 4e12bd5f85..27f3368216 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java @@ -523,8 +523,9 @@ public abstract class ElementCasePane 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 extends Tar FineLoggerFactory.getLogger().info("Nothing to release"); } this.selection = selection; + fireSelectionChanged(); } - fireSelectionChanged(); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index e2b13b1adf..63bc3d999b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/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 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