From f93ff0961cd29aa22775cec73ee1971a99855baf Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Tue, 19 Oct 2021 19:00:03 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-61125=20=E4=BA=A4=E4=BA=92=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guide/creator/GuideCreateUtils.java | 21 +++++++--- .../layout/ChangeLayoutComponentGuide.java | 24 ++--------- .../layout/UseLayoutAndComponentGuide.java | 37 ++++++++++++++-- .../theme/DownloadComponentPackageGuide.java | 42 ++++--------------- .../guide/creator/theme/ThemeToggleGuide.java | 10 +++-- 5 files changed, 68 insertions(+), 66 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java index 864459276..39c6b5574 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java @@ -31,6 +31,7 @@ import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JOptionPane; import javax.swing.JRootPane; +import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import java.awt.BorderLayout; @@ -231,7 +232,7 @@ public class GuideCreateUtils { int returnVal = FineJOptionPane.showConfirmDialog( DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Guide_Option_Confirm_Not_Login"), - Toolkit.i18nText("Fine-Design_Basic_Confirm"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (returnVal == JOptionPane.YES_OPTION) { @@ -243,16 +244,16 @@ public class GuideCreateUtils { FineJOptionPane.showMessageDialog( DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Guide_Option_Warning_Need_Network"), - Toolkit.i18nText("Fine-Design_Basic_Confirm"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); } public static void showNoFileAuthAlert() { FineJOptionPane.showMessageDialog( DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - JOptionPane.INFORMATION_MESSAGE + Toolkit.i18nText("Fine-Design_Guide_Option_Warning_No_Directory_Auth"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), + JOptionPane.WARNING_MESSAGE ); } @@ -292,4 +293,14 @@ public class GuideCreateUtils { return dialog; } + public static JScrollPane getParentScrollPane(Component component) { + if (component.getParent() == null) { + return null; + } + if (component.getParent() instanceof JScrollPane) { + return (JScrollPane) component.getParent(); + } + return getParentScrollPane(component.getParent()); + } + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/ChangeLayoutComponentGuide.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/ChangeLayoutComponentGuide.java index 6bf82065f..2058bf958 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/ChangeLayoutComponentGuide.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/ChangeLayoutComponentGuide.java @@ -35,10 +35,9 @@ public class ChangeLayoutComponentGuide { public static Guide createGuide() { GuideScene scene = createScene(); scene.nextScene(createScene2()) - .nextScene(createScene3()) .nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene()) - .nextScene(createScene4()) - .nextScene(createScene5()); + .nextScene(createScene3()) + .nextScene(createScene4()); Guide guide = GuideBuilder.newInstance() .setID(GuideIds.Guide.F001002) @@ -83,21 +82,6 @@ public class ChangeLayoutComponentGuide { } private static GuideScene createScene2() { - DisplayScene scene = new DisplayScene(); - scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { - @Override - public boolean prepared() { - scene.addCustomTarget( - GuideCreateUtils.createTarget(switchButton.getComponentPopupMenu()), - GuideCreateUtils.getRelativeBounds(switchButton.getComponentPopupMenu(), switchButton,0, -switchButton.getComponentPopupMenu().getHeight()) - ); - return true; - } - }); - return scene; - } - - private static GuideScene createScene3() { ClickScene scene = new ClickScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override @@ -117,7 +101,7 @@ public class ChangeLayoutComponentGuide { return scene; } - private static GuideScene createScene4() { + private static GuideScene createScene3() { DragScene scene = new DragScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override @@ -158,7 +142,7 @@ public class ChangeLayoutComponentGuide { return scene; } - private static GuideScene createScene5() { + private static GuideScene createScene4() { DisplayScene scene = new DisplayScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java index 6d67f3b93..0ea5b0645 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java @@ -1,18 +1,24 @@ package com.fr.design.mainframe.guide.creator.layout; +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.FormThemeConfig; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XOccupiedLayout; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.imenu.UIHeadMenu; import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormWidgetDetailPane; +import com.fr.design.mainframe.JForm; +import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.NorthRegionContainerPane; import com.fr.design.mainframe.guide.GuideIds; import com.fr.design.mainframe.guide.base.Guide; import com.fr.design.mainframe.guide.base.GuideBuilder; import com.fr.design.mainframe.guide.base.GuideLifecycleAdaptor; +import com.fr.design.mainframe.guide.base.GuideManager; import com.fr.design.mainframe.guide.creator.GuideCreateUtils; import com.fr.design.mainframe.guide.creator.GuideSceneHelper; import com.fr.design.mainframe.guide.scene.ClickScene; @@ -24,6 +30,7 @@ import com.fr.design.mainframe.guide.tip.GuideTip; import com.fr.design.mainframe.share.ui.block.LocalWidgetBlock; import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane; import com.fr.design.mainframe.share.util.InstallComponentHelper; +import com.fr.design.mainframe.theme.AsyncThemeFetcher; import com.fr.design.utils.ComponentUtils; import com.fr.design.widget.ui.designer.NewFormPane; import com.fr.design.widget.ui.designer.PredefinedLayoutPane; @@ -47,6 +54,7 @@ public class UseLayoutAndComponentGuide { private static final String RESOURCE_PATH = "/com/fr/report/guide/component"; private static UIHeadMenu fileHeadMenu; private static NewFormPane newFormPane; + private static String defaultThemeName; public static Guide createGuide() { GuideScene scene = createScene(); @@ -71,9 +79,23 @@ public class UseLayoutAndComponentGuide { @Override public boolean prepared() { preloadShareComponent(); - Component component = ComponentUtils.findComponentByName(NorthRegionContainerPane.getInstance(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_File")); - fileHeadMenu = ((UIHeadMenu) component); - return true; + List themeNames = FormThemeConfig.getInstance().getThemeNames(); + if (themeNames.size() > 0) { + defaultThemeName = themeNames.get(Math.max(themeNames.size() - 2, 0)); + AsyncThemeFetcher asyncThemeFetcher = new AsyncThemeFetcher<>(1, FormThemeConfig.getInstance()); + asyncThemeFetcher.submit(defaultThemeName, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter(){ + @Override + public void afterCachedFetch(FormTheme theme) { + Component component = ComponentUtils.findComponentByName(NorthRegionContainerPane.getInstance(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_File")); + fileHeadMenu = ((UIHeadMenu) component); + asyncThemeFetcher.shutdown(); + GuideManager.getInstance().getCurrentGuide().start(); + } + }); + } else { + GuideManager.getInstance().getCurrentGuide().terminate(); + } + return false; } @Override @@ -176,6 +198,15 @@ public class UseLayoutAndComponentGuide { public boolean onComplete() { newFormPane.createLayoutForm(); newFormPane.getWindow().dispose(); + FormTheme defaultTheme = FormThemeConfig.getInstance().cachedFetch(defaultThemeName); + if (defaultTheme != null) { + JTemplate newTemplate = DesignerContext.getDesignerFrame().getSelectedJTemplate(); + if (newTemplate instanceof JForm) { + JForm jForm = (JForm) newTemplate; + jForm.setTemplateTheme(defaultTheme); + } + + } return true; } }); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java index 68de9ef8f..2fdbe0699 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java @@ -43,6 +43,7 @@ import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import java.awt.Component; +import java.awt.Dimension; import java.awt.Point; import java.awt.event.ContainerAdapter; import java.awt.event.ContainerEvent; @@ -62,7 +63,6 @@ public class DownloadComponentPackageGuide { .nextScene(createScene3()) .nextScene(createScene4()) .nextScene(createScene5()) - .nextScene(createScene6()) .nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene()); Guide guide = GuideBuilder.newInstance() @@ -93,7 +93,7 @@ public class DownloadComponentPackageGuide { } boolean loadWidgetSuccess = OnlineWidgetRepoPane.loadWidgets(); if (loadWidgetSuccess) { - filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "layout_recommend", ".frm"); + filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "download_theme", ".frm"); if (filePath == null) { GuideCreateUtils.showNoFileAuthAlert(); GuideManager.getInstance().getCurrentGuide().terminate(); @@ -189,7 +189,7 @@ public class DownloadComponentPackageGuide { if (onlineWidgetPackageBlock == null) { GuideManager.getInstance().getCurrentGuide().terminate(); } else { - JScrollPane scrollPane = getParentScrollPane(onlineWidgetPackageBlock); + JScrollPane scrollPane = GuideCreateUtils.getParentScrollPane(onlineWidgetPackageBlock); scrollPane.getVerticalScrollBar().setValue(onlineWidgetPackageBlock.getY()); SwingUtilities.invokeLater(new Runnable() { @Override @@ -207,24 +207,6 @@ public class DownloadComponentPackageGuide { } private static GuideScene createScene3() { - DisplayScene scene = new DisplayScene(); - scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { - @Override - public boolean prepared() { - scene.addTarget(onlineWidgetPackageBlock); - JPopupMenu popupMenu = onlineWidgetPackageBlock.getRightClickPopupMenu(); - Point location = getPopupMenuLocation(); - scene.addCustomTarget( - GuideCreateUtils.createTarget(popupMenu), - GuideCreateUtils.getRelativeBounds(popupMenu, onlineWidgetPackageBlock, location.x, location.y) - ); - return true; - } - }); - return scene; - } - - private static GuideScene createScene4() { ClickScene scene = new ClickScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override @@ -260,7 +242,7 @@ public class DownloadComponentPackageGuide { return scene; } - private static GuideScene createScene5() { + private static GuideScene createScene4() { DisplayScene scene = new DisplayScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override @@ -279,7 +261,7 @@ public class DownloadComponentPackageGuide { return scene; } - private static GuideScene createScene6() { + private static GuideScene createScene5() { ClickScene scene = new ClickScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override @@ -305,7 +287,8 @@ public class DownloadComponentPackageGuide { private static Point getPopupMenuLocation() { JPopupMenu popupMenu = onlineWidgetPackageBlock.getRightClickPopupMenu(); - return new Point((onlineWidgetPackageBlock.getWidth() - popupMenu.getWidth()) / 2, (onlineWidgetPackageBlock.getHeight()- popupMenu.getHeight()) / 2); + Dimension preferredSize = popupMenu.getPreferredSize(); + return new Point((onlineWidgetPackageBlock.getWidth() - preferredSize.width) / 2, (onlineWidgetPackageBlock.getHeight()- preferredSize.height) / 2); } private static void closeConfirmDialog() { @@ -313,15 +296,4 @@ public class DownloadComponentPackageGuide { themeConfirmDialog.dispose(); } } - - private static JScrollPane getParentScrollPane(Component component) { - if (component.getParent() == null) { - return null; - } - if (component.getParent() instanceof JScrollPane) { - return (JScrollPane) component.getParent(); - } - return getParentScrollPane(component.getParent()); - } - } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java index 07fb60041..8baffb676 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java @@ -28,6 +28,7 @@ import com.fr.design.mainframe.theme.TemplateThemeGridPagesPane; import com.fr.design.mainframe.theme.dialog.TemplateThemeUsingDialog; import com.fr.design.utils.ComponentUtils; +import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import java.awt.Component; import java.util.List; @@ -35,7 +36,6 @@ import java.util.TimerTask; public class ThemeToggleGuide { private static final int PAGE_THEME_COUNT = 9; - private static final int DEFAULT_THEME_INDEX = 4; private static TemplateThemeUsingDialog themeDialog; private static String TARGET_XCREATOR_NAME = "chart00"; private static String filePath; @@ -64,11 +64,11 @@ public class ThemeToggleGuide { @Override public boolean prepared() { List themeNames = FormThemeConfig.getInstance().getThemeNames(); - themeLoadCount = Math.min(themeNames.size(), PAGE_THEME_COUNT); + themeLoadCount = themeNames.size(); if (themeLoadCount == 0) { GuideManager.getInstance().getCurrentGuide().terminate(); } - selectedThemeIndex = Math.min(themeLoadCount - 1, DEFAULT_THEME_INDEX); + selectedThemeIndex = Math.max(themeLoadCount - 5, 0); int lazyCount = themeLoadCount; AsyncThemeFetcher asyncThemeFetcher = new AsyncThemeFetcher<>(PAGE_THEME_COUNT, FormThemeConfig.getInstance()); for (int index = 0; index < lazyCount; index++) { @@ -230,7 +230,11 @@ public class ThemeToggleGuide { if (themeDialog == null) { themeDialog = new TemplateThemeUsingDialog(); } + String name = FormThemeConfig.getInstance().getThemeNames().get(selectedThemeIndex); + Component component = ComponentUtils.findComponentByName(themeDialog.getContentPane(), name); + JScrollPane scrollPane = GuideCreateUtils.getParentScrollPane(component); GuideCreateUtils.showDialogWithoutModal(themeDialog); + scrollPane.getVerticalScrollBar().setValue(component.getY()); } private static void closeTemplateThemeUsingDialog() {