From 56b32280f38684e44d1fb6a7345c5582799ec4b9 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 6 Jul 2021 13:48:20 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-53175=E3=80=9010.0.18=E3=80=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=E4=B8=BA=E6=A0=87?= =?UTF-8?q?=E9=A2=98/=E8=83=8C=E6=99=AF/=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 子功能: 组件样式支持图片边框 首次打开边框图片选择器的默认路径为assets/border_images, 后续打开路径为上次位置 --- .../gui/xpane/BorderLineAndImagePane.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java index 67eb8c1ae5..ca8b5abebd 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java @@ -5,6 +5,7 @@ import com.fr.base.Style; import com.fr.base.Utils; import com.fr.base.background.ImageBackground; import com.fr.base.background.ImageFileBackground; +import com.fr.config.ServerPreferenceConfig; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; import com.fr.design.designer.IntervalConstants; @@ -20,7 +21,6 @@ import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itooltip.UIToolTip; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -32,7 +32,10 @@ import com.fr.general.Background; import com.fr.general.IOUtils; import com.fr.stable.Constants; import com.fr.stable.GraphDrawHelper; +import com.fr.stable.ProjectLibrary; +import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; import javax.swing.*; import javax.swing.event.ChangeEvent; @@ -46,6 +49,7 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.geom.RoundRectangle2D; import java.awt.image.BufferedImage; +import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -174,6 +178,20 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { } } + private void initImageFileChooserDirectory() { + ServerPreferenceConfig config = ServerPreferenceConfig.getInstance(); + String lastUsedBorderImagesDirPath = config.getLastUsedBorderImagesDir(); + File lastUsedBorderImagesDir = StringUtils.isNotEmpty(lastUsedBorderImagesDirPath) ? new File(lastUsedBorderImagesDirPath) : null; + + File inbuiltBorderImagesDir = new File(StableUtils.pathJoin(ProjectLibrary.getInstance().getLibHome(), ProjectConstants.ASSETS_NAME, "border_images")); + + if (lastUsedBorderImagesDir!= null && lastUsedBorderImagesDir.exists()) { + imageFileChooser.setCurrentDirectory(lastUsedBorderImagesDir); + } else if (inbuiltBorderImagesDir.exists()) { + imageFileChooser.setCurrentDirectory(inbuiltBorderImagesDir); + } + } + protected void initNinePointTweakPaneIfNotExist() { if (tweakPane == null) { tweakPane = new NinePointImageTweakDialogPane(); @@ -210,8 +228,15 @@ public class BorderLineAndImagePane extends JPanel implements UIObserver { @Override public void actionPerformed(ActionEvent e) { initImageFileChooserIfNotExist(); - + initImageFileChooserDirectory(); int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + ServerPreferenceConfig config = ServerPreferenceConfig.getInstance(); + File selectedDirectory = imageFileChooser.getSelectedFile().getParentFile(); + config.setLastUsedBorderImagesDir(selectedDirectory.getPath()); + } + ImgChooseWrapper.getInstance(imagePreviewPane, imageFileChooser, DEFAULT_IMAGE_LAYOUT_STYLE, new ChangeListener() { @Override public void stateChanged(ChangeEvent e) {