From 2502b232a93886df2b1c96387a4ae48786a54099 Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Tue, 17 Aug 2021 18:02:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-56532=20=E6=96=87=E4=BB=B6=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E5=BC=B9=E7=AA=97=20&&=20REPORT-56683=20?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=80=89=E6=8B=A9=E5=99=A8=E5=BC=B9=E7=AA=97?= =?UTF-8?q?-=E5=9B=BE=E7=89=87=E5=8E=8B=E7=BC=A9=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E8=BF=81=E7=A7=BB=E7=9A=84=E5=88=9D=E6=AC=A1?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/file/PreferencePane.java | 2 +- .../ifilechooser/JavaFxNativeFileChooser.java | 87 ++++++++++++++++--- .../background/image/ImageFileChooser.java | 15 ++-- 3 files changed, 86 insertions(+), 18 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index a41f96295..24e359d6f 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -503,7 +503,7 @@ public class PreferencePane extends BasicPane { new JavaFxNativeFileChooser.Builder(). fileSelectionMode(FileSelectionMode.DIR). build(); - int saveValue = fileChooserProvider.showDialog(null); + int saveValue = fileChooserProvider.showDialog(chooseDirBtn); if (saveValue == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooserProvider.getSelectedFile(); logExportDirectoryField.setText(selectedFile.getAbsolutePath()); diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java index b5fce35db..038212bfd 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java @@ -2,16 +2,22 @@ package com.fr.design.gui.ifilechooser; import com.fr.design.i18n.Toolkit; -import com.fr.design.upm.UpmUtils; +import com.fr.design.mainframe.DesignerContext; import com.fr.log.FineLoggerFactory; -import com.fr.stable.StringUtils; import com.sun.javafx.application.PlatformImpl; +import javafx.application.Platform; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.paint.Color; import javafx.stage.DirectoryChooser; import javafx.stage.FileChooser; -import javafx.stage.Window; +import javafx.stage.Modality; +import javafx.stage.Stage; +import javafx.stage.StageStyle; import javax.swing.*; -import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.*; import java.io.File; import java.util.List; @@ -40,9 +46,17 @@ public class JavaFxNativeFileChooser implements FileChooserProvider { @Override public int showDialog(Component parent) { final CountDownLatch latch = new CountDownLatch(1); - PlatformImpl.startup(new Runnable() { + PlatformImpl.startup(() -> { + }); + Platform.setImplicitExit(false); + Platform.runLater(new Runnable() { @Override public void run() { + Component fileChooserParent = parent; + if (fileChooserParent == null) { + fileChooserParent = DesignerContext.getDesignerFrame(); + } + Stage stage = showCoverStage(fileChooserParent); try { if (fileSelectionMode == FileSelectionMode.FILE || fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { FileChooser fileChooser = new FileChooser(); @@ -50,12 +64,12 @@ public class JavaFxNativeFileChooser implements FileChooserProvider { fileChooser.getExtensionFilters().addAll(filters); fileChooser.setInitialDirectory(currentDirectory); if (fileSelectionMode == FileSelectionMode.FILE) { - File file = fileChooser.showOpenDialog(null); + File file = fileChooser.showOpenDialog(stage); if (file != null) { selectedFiles = new File[]{file}; } } else if (fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { - List fileList = fileChooser.showOpenMultipleDialog(null); + List fileList = fileChooser.showOpenMultipleDialog(stage); if (fileList != null) { selectedFiles = new File[fileList.size()]; fileList.toArray(selectedFiles); @@ -65,17 +79,70 @@ public class JavaFxNativeFileChooser implements FileChooserProvider { DirectoryChooser directoryChooser = new DirectoryChooser(); directoryChooser.setTitle(title); directoryChooser.setInitialDirectory(currentDirectory); - File folder = directoryChooser.showDialog(null); + File folder = directoryChooser.showDialog(stage); if (folder != null) { selectedFiles = new File[]{folder}; } - System.out.println(folder); } - } catch (Exception e) { FineLoggerFactory.getLogger().error(e, e.getMessage()); } finally { latch.countDown(); + closeCoverStage(stage); + } + } + + private void closeCoverStage(Stage stage) { + if (stage != null) { + stage.close(); + closeCoverStage((Stage) stage.getOwner()); + } + + } + + + private Stage showCoverStage(Component component) { + try { + if (component == null) + return null; + Stage parentStage = showCoverStage(component.getParent()); + if (component instanceof JDialog || component instanceof JFrame) { + return createStage(component.getX(), component.getY(), component.getWidth(), component.getHeight(), parentStage); + } else { + return parentStage; + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + return null; + } + } + + private Stage createStage(double x, double y, double w, double h, Stage parentStage) { + try { + Stage stage = new Stage(); + stage.setX(x); + stage.setY(y); + stage.setWidth(w); + stage.setHeight(h); + stage.setOpacity(0.2); + stage.setResizable(false); + stage.initStyle(StageStyle.UNDECORATED); + + Label label = new Label(); + label.setBackground( + new Background(new BackgroundFill(Color.color(0.78, 0.78, 0.80, 0.5), null, null))); + stage.setScene(new Scene(label)); + + + if (parentStage != null) { + stage.initOwner(parentStage); + stage.initModality(Modality.WINDOW_MODAL); + } + stage.show(); + return stage; + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + return null; } } }); diff --git a/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java b/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java index 57f0d59d6..9c5b1af4d 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java +++ b/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java @@ -32,11 +32,7 @@ public class ImageFileChooser { new JavaFxNativeFileChooser.Builder(). fileSelectionMode(FileSelectionMode.FILE). title(Toolkit.i18nText("Fine-Design_Basic_Open")). - filters(new FileChooser.ExtensionFilter[]{ - new FileChooser.ExtensionFilter("jpg", "*.jpg"), - new FileChooser.ExtensionFilter("gif", "*.gif"), - new FileChooser.ExtensionFilter("png", "*.png"), - new FileChooser.ExtensionFilter("bmp", "*.bmp")}). + filter(Toolkit.i18nText("Fine-Design_Basic_Image_Image_Files"), "*.jpg", "*.gif", "*.png", "*.bmp"). build(); } @@ -72,8 +68,13 @@ public class ImageFileChooser { private void showImageCompressMoveTip() { if (DesignerEnvManager.getEnvManager().isShowImageCompressMoveTip()) { - DesignerToastMsgUtil.toastWarning(Toolkit.i18nText("Fine-Design_Image_Compress_Move_Tip")); - DesignerEnvManager.getEnvManager().setShowImageCompressMoveTip(false); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + DesignerToastMsgUtil.toastWarning(Toolkit.i18nText("Fine-Design_Image_Compress_Move_Tip")); + DesignerEnvManager.getEnvManager().setShowImageCompressMoveTip(false); + } + }); } } } From 42f24c5bcf1f09c2421cad431eac7d087bb396b6 Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 18 Aug 2021 10:10:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-55756=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E7=A7=BB=E5=8A=A8=E6=97=B6=EF=BC=8C=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=A0=8F=E4=BF=9D=E6=8C=81=E5=81=9C=E7=95=99=E5=8E=9F?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=EF=BC=8C=E6=B2=A1=E6=9C=89=E9=9A=8F=E7=9D=80?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=EF=BC=8C=E8=BF=99=E4=B8=AA=E7=9C=8B=E4=B8=8B?= =?UTF-8?q?=E8=A6=81=E4=B8=8D=E8=A6=81=E4=BC=98=E5=8C=96=E4=B8=8B=E3=80=82?= =?UTF-8?q?=E9=BC=A0=E6=A0=87=E5=86=8D=E5=9B=9E=E5=88=B0=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E7=94=BB=E5=B8=83=E5=B0=B1=E5=A5=BD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/PluginClassRefreshManager.java | 18 ++++++++++++++++-- .../com/fr/design/mainframe/DesignerFrame.java | 8 ++++++++ .../com/fr/design/mainframe/JTemplate.java | 4 ++++ .../java/com/fr/design/mainframe/JForm.java | 7 +++++++ .../com/fr/design/mainframe/JWorkBook.java | 8 ++++++++ 5 files changed, 43 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java b/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java index 9e1d57dfd..4e81a7ece 100644 --- a/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java +++ b/designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java @@ -4,6 +4,8 @@ import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.fun.HyperlinkProvider; import com.fr.design.fun.TableDataDefineProvider; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.ui.util.UIUtil; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventType; @@ -28,7 +30,7 @@ public class PluginClassRefreshManager { @Override public void on(PluginEvent event) { // 重载模版之前 触发下hide - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); + fireTabChange(); // 兼容之前版本特性 for (String tag : context) { if (event.getContext().contain(tag)) { @@ -53,12 +55,24 @@ public class PluginClassRefreshManager { public void on(PluginEvent event) { PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener); if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) { - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange(); + fireTabChange(); HistoryTemplateListCache.getInstance().reloadAllEditingTemplate(); } } }; + public void fireTabChange() { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + template.fireTabChange(); + } + }); + } + } + public static PluginClassRefreshManager getInstance() { return INSTANCE; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 39cdbb930..a5784959a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -275,6 +275,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta //刷新FixedPopupPane的位置 EastRegionContainerPane.getInstance().freshCurrentPopupPane(); } + + @Override + public void componentMoved(ComponentEvent e) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + template.refreshFormDesigner(); + } + } }); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.setVisible(false); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 8b76b30f4..79f6a5c1e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -221,6 +221,10 @@ public abstract class JTemplate> // do nothing } + public void refreshFormDesigner() { + // do nothing + } + /** * @deprecated move to cloud ops plugin,left only for compatible diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 8c9b1f2bc..0bee88e90 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -1135,4 +1135,11 @@ public class JForm extends JTemplate implements BaseJForm { designer.hidePopup(); } } + + @Override + public void refreshFormDesigner() { + FormDesigner designer = (FormDesigner) parameterPane.getParaDesigner(); + if (designer != null) { + designer.repaint(); + } + } }