From e950feb1f5ecbaa057cc36c8bbcc56d40e15a221 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 9 Sep 2019 13:45:47 +0800 Subject: [PATCH 1/9] =?UTF-8?q?REPORT-21202=20tab=E5=9D=97=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E8=8F=9C=E5=8D=95=E6=A0=B7=E5=BC=8F=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E6=94=B9=E4=B8=8D=E5=9B=9E=E9=BB=98=E8=AE=A4=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/beans/models/SelectionModel.java | 47 +++++++------------ .../fr/design/mainframe/FormSelection.java | 6 ++- 2 files changed, 21 insertions(+), 32 deletions(-) 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 c7121f0e16..76eb602300 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,7 +18,9 @@ import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.stable.ArrayUtils; -import java.awt.*; +import java.awt.LayoutManager; +import java.awt.Rectangle; +import java.awt.Toolkit; import java.awt.event.MouseEvent; import java.util.ArrayList; @@ -175,36 +177,19 @@ public class SelectionModel { } 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); - } + //自适应布局编辑器内部左上角第一个坐标点 + 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 { - //自适应布局编辑器内部左上角第一个坐标点 - 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); - } + FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), + clipboard, + rectangle.x + rectangle.width / 2, + rectangle.y + DELTA_X_Y); } } @@ -497,4 +482,4 @@ public class SelectionModel { selection.setSelectedCreators(rebuildSelection); fireCreatorSelected(); } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java index 8d223c2452..c7d7d8c157 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java @@ -11,6 +11,7 @@ import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; +import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.Widget; @@ -317,6 +318,9 @@ public class FormSelection { clipBoard.reset(); for (XCreator root : selection) { + if(root.acceptType(XWTabFitLayout.class)){ + continue; + } try { XCreator creator = XCreatorUtils.createXCreator((Widget) root.toData().clone()); creator.setBounds(root.getBounds()); @@ -326,4 +330,4 @@ public class FormSelection { } } } -} \ No newline at end of file +} From 8141138aaeb2d658902d5feaad7c2b142c65fc2e Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 17 Sep 2019 09:34:53 +0800 Subject: [PATCH 2/9] =?UTF-8?q?REPORT-21486=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=20=E5=8F=8C=E5=B1=8F=E6=83=85=E5=86=B5=EF=BC=8C=E5=8F=96?= =?UTF-8?q?=E8=89=B2=E5=99=A8=E7=BB=8F=E8=BF=87=E5=8F=8C=E5=B1=8F=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E5=A4=84=E4=BC=9A=E5=8D=A1=E6=AD=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/style/color/ColorPicker.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java b/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java index 155ac4168b..d8816c3e3f 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java @@ -167,17 +167,18 @@ class ColorPickerPanel extends JPanel * 截屏 */ public void captureScreen() { - try - { + try { robot = new Robot(); } - catch (AWTException e) - { + catch (AWTException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } // 截屏幕 - screenImage = robot.createScreenCapture(new Rectangle(0, 0, Toolkit - .getDefaultToolkit().getScreenSize().width, Toolkit - .getDefaultToolkit().getScreenSize().height)); + Rectangle rectangle = new Rectangle(0, 0, 0, 0); + for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) { + rectangle = rectangle.union(gd.getDefaultConfiguration().getBounds()); + } + screenImage = robot.createScreenCapture(rectangle); } /** From db8e1b7e14879267db768fca69ff7d51d7711799 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Fri, 27 Sep 2019 14:48:00 +0800 Subject: [PATCH 3/9] =?UTF-8?q?REPORT-22114=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E9=85=8D=E7=BD=AE=E7=95=8C=E9=9D=A2=E4=BC=98=E5=85=88?= =?UTF-8?q?=E4=BB=A5=E7=9B=B4=E6=8E=A5=20url=20=E5=9C=B0=E5=9D=80=E5=A1=AB?= =?UTF-8?q?=E5=86=99=E7=9A=84=E4=B8=BA=E5=87=86=E5=B9=B6=E5=B0=BD=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E4=BF=9D=E8=AF=81=E8=81=94=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/env/RemoteEnvPane.java | 1 + .../java/com/fr/env/RemoteWorkspaceURL.java | 36 ++++++++++--------- ...LTest.java => RemoteWorkspaceURLTest.java} | 35 +++++++++++++++++- 3 files changed, 54 insertions(+), 18 deletions(-) rename designer-base/src/test/java/com/fr/env/{RemoteEnvURLTest.java => RemoteWorkspaceURLTest.java} (81%) diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 9b97c43599..1e80ae9ec4 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -643,6 +643,7 @@ public class RemoteEnvPane extends BasicBeanPane { remoteWorkspaceURL.setPort(port); remoteWorkspaceURL.setWeb(web); remoteWorkspaceURL.setServlet(servlet); + remoteWorkspaceURL.resetUrl(); } diff --git a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java index f7f5e6aeeb..06e38a5cc8 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java +++ b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java @@ -1,10 +1,9 @@ package com.fr.env; +import com.fr.stable.AssistUtils; import com.fr.stable.FCloneable; import com.fr.stable.StringUtils; -import java.util.Objects; - /** * @author yaohwu */ @@ -42,6 +41,7 @@ public class RemoteWorkspaceURL implements FCloneable { private String port; private String web; private String servlet; + private String url; /** @@ -51,7 +51,7 @@ public class RemoteWorkspaceURL implements FCloneable { * @param url x:x/x/x/x */ public RemoteWorkspaceURL(String url) { - + this.url = url; // 没有写协议名称 默认 使用 http 协议 if (!url.startsWith(HTTPS) && !url.startsWith(HTTP)) { url = HTTP + url; @@ -116,11 +116,15 @@ public class RemoteWorkspaceURL implements FCloneable { } public String getURL() { + if (this.url != null) { + return url; + } String prefix = isHttps ? HTTPS : HTTP; String portColon = StringUtils.isNotEmpty(port) ? ":" : StringUtils.EMPTY; String webAppNameSlash = StringUtils.isNotEmpty(web) ? "/" : StringUtils.EMPTY; String servletNameSlash = StringUtils.isNotEmpty(servlet) ? "/" : StringUtils.EMPTY; - return prefix + host + portColon + port + webAppNameSlash + web + servletNameSlash + servlet; + this.url = prefix + host + portColon + port + webAppNameSlash + web + servletNameSlash + servlet; + return this.url; } @@ -164,26 +168,24 @@ public class RemoteWorkspaceURL implements FCloneable { return servlet; } + public void resetUrl() { + this.url = null; + } + @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - RemoteWorkspaceURL that = (RemoteWorkspaceURL) o; - return isHttps == that.isHttps && - Objects.equals(host, that.host) && - Objects.equals(port, that.port) && - Objects.equals(web, that.web) && - Objects.equals(servlet, that.servlet); + return o instanceof RemoteWorkspaceURL && AssistUtils.equals(isHttps, ((RemoteWorkspaceURL) o).isHttps) + && AssistUtils.equals(host, ((RemoteWorkspaceURL) o).host) + && AssistUtils.equals(port, ((RemoteWorkspaceURL) o).port) + && AssistUtils.equals(web, ((RemoteWorkspaceURL) o).web) + && AssistUtils.equals(servlet, ((RemoteWorkspaceURL) o).servlet) + && AssistUtils.equals(url, ((RemoteWorkspaceURL) o).url); } @Override public int hashCode() { - return Objects.hash(isHttps, host, port, web, servlet); + return AssistUtils.hashCode(isHttps, host, port, web, servlet, url); } @Override diff --git a/designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java b/designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java similarity index 81% rename from designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java rename to designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java index 2c6a0ab39a..731093c153 100644 --- a/designer-base/src/test/java/com/fr/env/RemoteEnvURLTest.java +++ b/designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java @@ -8,7 +8,40 @@ import static org.junit.Assert.assertEquals; /** * @author yaohwu */ -public class RemoteEnvURLTest { +public class RemoteWorkspaceURLTest { + + + @Test + public void testUrlReset() { + + String a = "https://yaohwu:8080/webroot/app/c/d"; + RemoteWorkspaceURL workspaceURL = new RemoteWorkspaceURL(a); + Assert.assertEquals(a, workspaceURL.getURL()); + Assert.assertEquals("app", workspaceURL.getServlet()); + Assert.assertEquals("webroot", workspaceURL.getWeb()); + Assert.assertEquals("yaohwu", workspaceURL.getHost()); + Assert.assertEquals("8080", workspaceURL.getPort()); + Assert.assertTrue(workspaceURL.getHttps()); + + workspaceURL.setHttps(false); + workspaceURL.setHost("finereport"); + + Assert.assertEquals(a, workspaceURL.getURL()); + Assert.assertEquals("app", workspaceURL.getServlet()); + Assert.assertEquals("webroot", workspaceURL.getWeb()); + Assert.assertEquals("finereport", workspaceURL.getHost()); + Assert.assertEquals("8080", workspaceURL.getPort()); + Assert.assertFalse(workspaceURL.getHttps()); + + workspaceURL.resetUrl(); + + Assert.assertEquals("http://finereport:8080/webroot/app", workspaceURL.getURL()); + Assert.assertEquals("app", workspaceURL.getServlet()); + Assert.assertEquals("webroot", workspaceURL.getWeb()); + Assert.assertEquals("finereport", workspaceURL.getHost()); + Assert.assertEquals("8080", workspaceURL.getPort()); + Assert.assertFalse(workspaceURL.getHttps()); + } @Test public void testURLParser() { From c15d8fdd5a52a9026eb85de9fd60971761078a1d Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Fri, 27 Sep 2019 14:51:29 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20toString=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=B1=95=E7=A4=BA=E5=AE=8C=E6=95=B4=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java index 06e38a5cc8..dee40422c7 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java +++ b/designer-base/src/main/java/com/fr/env/RemoteWorkspaceURL.java @@ -196,6 +196,7 @@ public class RemoteWorkspaceURL implements FCloneable { ", port='" + port + '\'' + ", web='" + web + '\'' + ", servlet='" + servlet + '\'' + + ", url='" + url + '\'' + '}'; } From 578b9a8b94d4fe452c710cd18cc8f31236e872c4 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Fri, 27 Sep 2019 14:56:40 +0800 Subject: [PATCH 5/9] =?UTF-8?q?hashCode=20=E5=92=8C=20equals=20=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/env/RemoteWorkspaceURLTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java b/designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java index 731093c153..f066ae6896 100644 --- a/designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java +++ b/designer-base/src/test/java/com/fr/env/RemoteWorkspaceURLTest.java @@ -4,6 +4,7 @@ import org.junit.Assert; import org.junit.Test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; /** * @author yaohwu @@ -11,6 +12,18 @@ import static org.junit.Assert.assertEquals; public class RemoteWorkspaceURLTest { + @Test + public void testEqualAndHashCode() { + String a = "https://yaohwu:8080/webroot/app/c/d"; + RemoteWorkspaceURL workspaceURL1 = new RemoteWorkspaceURL(a); + RemoteWorkspaceURL workspaceURL2 = new RemoteWorkspaceURL(a); + assertEquals(workspaceURL1.hashCode(), workspaceURL2.hashCode()); + assertEquals(workspaceURL1, workspaceURL2); + workspaceURL2.resetUrl(); + assertNotEquals(workspaceURL1.hashCode(), workspaceURL2.hashCode()); + assertNotEquals(workspaceURL1, workspaceURL2); + } + @Test public void testUrlReset() { From 3c4c2cbd4635998cb88726230ccb84ba11c69f03 Mon Sep 17 00:00:00 2001 From: "Bruce.Deng" Date: Sun, 29 Sep 2019 11:52:22 +0800 Subject: [PATCH 6/9] =?UTF-8?q?REPORT-21556=20=E5=AF=BC=E5=85=A5excel?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/javascript/Commit2DBJavaScriptPane.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java b/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java index dbccb7c50c..d408950237 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/Commit2DBJavaScriptPane.java @@ -149,6 +149,8 @@ public class Commit2DBJavaScriptPane extends FurtherBasicBeanPane Date: Tue, 8 Oct 2019 18:34:44 +0800 Subject: [PATCH 7/9] =?UTF-8?q?REPORT-22410=2010.0=E5=88=A0=E9=99=A4tab?= =?UTF-8?q?=E6=97=B6=E5=BC=B9=E7=AA=97=E5=86=99=E7=9A=84Finereport8.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/creator/cardlayout/XCardSwitchButton.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index 72d0669c83..b1f1fb636b 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -32,6 +32,7 @@ import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; import com.fr.general.cardtag.TemplateStyle; +import com.fr.stable.ProductConstants; import com.fr.stable.unit.PT; import javax.swing.Action; @@ -221,7 +222,7 @@ public class XCardSwitchButton extends XButton { private void deleteCard(XCardSwitchButton button, int index){ String titleName = button.getContentLabel().getText(); int value = JOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Confirm_Dialog_Content") + "“" + titleName + "”", - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_ConfirmDialog_Title"), JOptionPane.YES_NO_OPTION); + ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION); if (value != JOptionPane.OK_OPTION) { return; } @@ -363,7 +364,7 @@ public class XCardSwitchButton extends XButton { private void deleteTabLayout(SelectionModel selectionModel, FormDesigner designer){ String titleName = this.getContentLabel().getText(); int value = JOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Confirm_Dialog_Content") + "“" + titleName + "”", - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_ConfirmDialog_Title"),JOptionPane.YES_NO_OPTION); + ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION); if (value != JOptionPane.OK_OPTION) { return; } From a4e936a433ebd5611bc8f8db585dd58083d99fa5 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 9 Oct 2019 16:12:02 +0800 Subject: [PATCH 8/9] =?UTF-8?q?REPORT-21486=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=20=E5=8F=96=E8=89=B2=E5=99=A8=20=E5=8F=8C=E5=B1=8F=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=20=E5=9C=A8=E4=BA=A4=E6=8D=A2=E5=B1=8F?= =?UTF-8?q?=E5=B9=95=E4=BD=8D=E7=BD=AE=E5=90=8E=20=E4=BB=8D=E6=9C=89?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E4=BA=8C=E9=97=AE=E9=A2=98=20&&=20REPORT-222?= =?UTF-8?q?14=20=E7=A6=81=E6=AD=A2=E4=BF=AE=E6=94=B9=E6=8E=A7=E4=BB=B6js?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/style/color/ColorPicker.java | 96 +++++++++++-------- .../com/fr/design/utils/gui/GUICoreUtils.java | 26 ++--- .../properties/EventPropertyTable.java | 1 + 3 files changed, 68 insertions(+), 55 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java b/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java index d8816c3e3f..6c1808fc05 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java @@ -4,7 +4,8 @@ package com.fr.design.style.color; * Created by plough on 2016/12/22. */ -import com.fr.base.BaseUtils; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import javax.swing.*; @@ -19,8 +20,7 @@ import java.awt.image.BufferedImage; /** * 取色框 */ -public class ColorPicker extends JDialog implements ActionListener -{ +public class ColorPicker extends JDialog implements ActionListener { private Container container = getContentPane(); // 主容器 private int setCoordinateX; // 取色框x坐标 private int setCoordinateY; // 取色框y坐标 @@ -42,8 +42,7 @@ public class ColorPicker extends JDialog implements ActionListener /** * 构造函数,创建一个取色框窗体 */ - public ColorPicker(ColorSelectable colorSelectable, Boolean setColorRealTime) - { + public ColorPicker(ColorSelectable colorSelectable, Boolean setColorRealTime) { setUndecorated(true); // 去掉窗体边缘 setResizable(false); Shape shape = new Ellipse2D.Double(0, 0, colorPickerSize, colorPickerSize); @@ -77,7 +76,6 @@ public class ColorPicker extends JDialog implements ActionListener } colorPickerPanel.captureScreen(); } -// System.out.println(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow()); } /** @@ -94,11 +92,33 @@ public class ColorPicker extends JDialog implements ActionListener public void updateLocation() { mousePos = MouseInfo.getPointerInfo().getLocation(); - setCoordinateX = mousePos.x - getSize().width/2; - setCoordinateY = mousePos.y- getSize().height/2; + updateCoordinate(); + setLocation(setCoordinateX, setCoordinateY); + updateMousePos(); + updateCoordinate(); colorPickerPanel.setMagnifierLocation(setCoordinateX, setCoordinateY); - setLocation(setCoordinateX, setCoordinateY); + + } + + private void updateCoordinate() { + setCoordinateX = mousePos.x - getSize().width / 2; + setCoordinateY = mousePos.y - getSize().height / 2; + } + + /** + * 兼容多屏下鼠标位置的计算 + */ + private void updateMousePos() { + Rectangle bounds = GUICoreUtils.getRectScreen(); + mousePos.x -= bounds.x; + mousePos.y -= bounds.y; + if (mousePos.x < 0) { + mousePos.x *= -1; + } + if (mousePos.y < 0) { + mousePos.y *= -1; + } } /** @@ -106,8 +126,7 @@ public class ColorPicker extends JDialog implements ActionListener * * @param colorPickerSize 取色框尺寸 */ - public void updateSize(int colorPickerSize) - { + public void updateSize(int colorPickerSize) { colorPickerPanel.setColorPickerSize(colorPickerSize); setSize(colorPickerSize, colorPickerSize); validate(); // 更新所有子控件 @@ -124,20 +143,19 @@ public class ColorPicker extends JDialog implements ActionListener // 隐藏鼠标光标 public void hideCursor() { Image imageCursor = Toolkit.getDefaultToolkit().getImage(""); - Cursor cu = Toolkit.getDefaultToolkit().createCustomCursor(imageCursor, new Point(0,0), "cursor"); + Cursor cu = Toolkit.getDefaultToolkit().createCustomCursor(imageCursor, new Point(0, 0), "cursor"); setCursor(cu); } - private class MouseFunctions extends MouseAdapter - { + private class MouseFunctions extends MouseAdapter { + @Override public void mousePressed(MouseEvent e) { - pickComplete(e.getButton() == e.BUTTON1); // 左键确定 + pickComplete(e.getButton() == MouseEvent.BUTTON1); // 左键确定 } } } -class ColorPickerPanel extends JPanel -{ +class ColorPickerPanel extends JPanel { private BufferedImage screenImage; private Image colorPickerFrame; // 取色框的边框图案 private int colorPickerSize; // 取色框尺寸 @@ -154,11 +172,11 @@ class ColorPickerPanel extends JPanel /** * 带参数的构造函数 - * @param scaleFactor 放大倍数 + * + * @param scaleFactor 放大倍数 */ - public ColorPickerPanel(int scaleFactor) - { - colorPickerFrame = BaseUtils.readImage("/com/fr/design/images/gui/colorPicker/colorPickerFrame.png"); + public ColorPickerPanel(int scaleFactor) { + colorPickerFrame = IOUtils.readImage("/com/fr/design/images/gui/colorPicker/colorPickerFrame.png"); this.scaleFactor = scaleFactor; captureScreen(); } @@ -169,25 +187,20 @@ class ColorPickerPanel extends JPanel public void captureScreen() { try { robot = new Robot(); - } - catch (AWTException e) { + } catch (AWTException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } // 截屏幕 - Rectangle rectangle = new Rectangle(0, 0, 0, 0); - for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) { - rectangle = rectangle.union(gd.getDefaultConfiguration().getBounds()); - } - screenImage = robot.createScreenCapture(rectangle); + screenImage = robot.createScreenCapture(GUICoreUtils.getRectScreen()); } /** * 设置取色框的位置 - * @param locationX x坐标 - * @param locationY y坐标 + * + * @param locationX x坐标 + * @param locationY y坐标 */ - public void setMagnifierLocation(int locationX, int locationY) - { + public void setMagnifierLocation(int locationX, int locationY) { this.locationX = locationX; this.locationY = locationY; repaint(); // 注意重画控件 @@ -201,17 +214,16 @@ class ColorPickerPanel extends JPanel return new Color(R, G, B); } - public void setColorPickerSize(int colorPickerSize) - { + public void setColorPickerSize(int colorPickerSize) { this.colorPickerSize = colorPickerSize; } - public void paintComponent(Graphics g) - { + @Override + public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - double pixelCount = (double)colorPickerSize / scaleFactor; // 取色器一条边上的放大后的像素点个数(可以是小数) + double pixelCount = (double) colorPickerSize / scaleFactor; // 取色器一条边上的放大后的像素点个数(可以是小数) // 关键处理代码 g2d.drawImage( screenImage, // 要画的图片 @@ -219,10 +231,10 @@ class ColorPickerPanel extends JPanel 0, // 目标矩形的第一个角的y坐标 colorPickerSize, // 目标矩形的第二个角的x坐标 colorPickerSize, // 目标矩形的第二个角的y坐标 - locationX + (int)((colorPickerSize - pixelCount) * 0.5) + 1, // 源矩形的第一个角的x坐标 - locationY + (int)((colorPickerSize - pixelCount) * 0.5) + 1, // 源矩形的第一个角的y坐标 - locationX + (int)((colorPickerSize + pixelCount) * 0.5) + 1, // 源矩形的第二个角的x坐标 - locationY + (int)((colorPickerSize + pixelCount) * 0.5) + 1, // 源矩形的第二个角的y坐标 + locationX + (int) ((colorPickerSize - pixelCount) * 0.5) + 1, // 源矩形的第一个角的x坐标 + locationY + (int) ((colorPickerSize - pixelCount) * 0.5) + 1, // 源矩形的第一个角的y坐标 + locationX + (int) ((colorPickerSize + pixelCount) * 0.5) + 1, // 源矩形的第二个角的x坐标 + locationY + (int) ((colorPickerSize + pixelCount) * 0.5) + 1, // 源矩形的第二个角的y坐标 this ); g2d.drawImage(colorPickerFrame, 0, 0, this); diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java index c8c0561c90..fdc0d0f0c7 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java @@ -60,19 +60,7 @@ import javax.swing.border.TitledBorder; import javax.swing.event.ChangeListener; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.GridLayout; -import java.awt.Image; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Toolkit; -import java.awt.Window; +import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -962,4 +950,16 @@ public final class GUICoreUtils { } return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 10); } + + /** + * 获取当前所有显示器设备的总长总宽 + * @return + */ + public static Rectangle getRectScreen() { + Rectangle rectangle = new Rectangle(0, 0, 0, 0); + for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) { + rectangle = rectangle.union(gd.getDefaultConfiguration().getBounds()); + } + return rectangle; + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/properties/EventPropertyTable.java b/designer-form/src/main/java/com/fr/design/designer/properties/EventPropertyTable.java index 1592b0fd01..ec953b9da3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/properties/EventPropertyTable.java +++ b/designer-form/src/main/java/com/fr/design/designer/properties/EventPropertyTable.java @@ -28,6 +28,7 @@ public class EventPropertyTable extends UIListControlPane { public EventPropertyTable(FormDesigner designer) { super(); + this.setNameListEditable(false); this.designer = designer; } From 514844ae5f9f767f7ecfb9b83492104c7ec58524 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 9 Oct 2019 16:16:04 +0800 Subject: [PATCH 9/9] update --- .../com/fr/design/utils/gui/GUICoreUtils.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java index fdc0d0f0c7..22107bf8ad 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java @@ -60,12 +60,26 @@ import javax.swing.border.TitledBorder; import javax.swing.event.ChangeListener; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.Image; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.Window; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.util.ArrayList; import java.util.Arrays; import java.util.List;