From dbf6e41c51302ab122df6fccffe293f2fd659302 Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Mon, 27 Sep 2021 22:53:47 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-57813=20=E4=BF=AE=E6=94=B9=E9=83=A8?= =?UTF-8?q?=E5=88=86=E9=97=A8=E6=A7=9B=E7=94=A8=E4=BE=8B=E5=8F=91=E7=8E=B0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/guide/base/Guide.java | 9 +- .../mainframe/guide/base/GuideManager.java | 71 ++++++--- .../mainframe/guide/base/GuideVersion.java | 29 ++++ .../mainframe/guide/base/GuideView.java | 80 +++++----- .../guide/scene/AbstractGuideScene.java | 147 ++++++++++++++---- .../mainframe/guide/scene/ClickScene.java | 11 ++ .../design/mainframe/guide/tip/BubbleTip.java | 16 +- .../guide/ui/GuideCompleteDialog.java | 2 +- .../mainframe/guide/ui/GuideManageDialog.java | 19 ++- .../mainframe/guide/utils/ScreenImage.java | 2 +- .../widget/ui/designer/NewFormPane.java | 10 +- .../fr/design/mainframe/guide/GuideIds.java | 4 + .../design/mainframe/guide/GuideRegister.java | 4 +- .../layout/UseLayoutAndComponentGuide.java | 3 +- .../guide/creator/theme/ThemeToggleGuide.java | 70 ++++----- 15 files changed, 330 insertions(+), 147 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideVersion.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/Guide.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/Guide.java index 003f229088..5f5747c59c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/Guide.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/Guide.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.guide.base; import com.fr.design.mainframe.guide.collect.GuideCollector; import com.fr.design.mainframe.guide.scene.GuideScene; import com.fr.design.mainframe.guide.ui.GuideCompleteDialog; +import com.fr.design.mainframe.guide.ui.GuideManageDialog; import com.fr.stable.StringUtils; import javax.swing.SwingUtilities; @@ -94,6 +95,10 @@ public class Guide { * 开启引导流程 */ public void go() { + // 同时只能启动一个引导 + if (GuideManager.getInstance().getCurrentGuide() != null) { + return; + } try { if (lifecycle != null && !lifecycle.prepared()) { return; @@ -131,8 +136,9 @@ public class Guide { } setComplete(true); GuideCollector.getInstance().saveInfo(); - end(); + guideView.dismissGuide(); GuideCompleteDialog.getInstance().showDialog(getName()); + end(); } public void terminate() { @@ -148,6 +154,7 @@ public class Guide { if (lifecycle != null) { lifecycle.onEnd(); } + GuideManageDialog.getInstance().showDialog(); } public void registerLifecycle(GuideLifecycle lifecycle) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideManager.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideManager.java index d9c2ac061e..b14cae4866 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideManager.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideManager.java @@ -7,10 +7,11 @@ import java.util.ArrayList; import java.util.List; public class GuideManager { - private Guide currentGuide; - private List guideGroupList; private static GuideManager guideManager; + private Guide currentGuide; + private List guideVersionList; + public static GuideManager getInstance() { if (guideManager == null) { guideManager = new GuideManager(); @@ -19,7 +20,7 @@ public class GuideManager { } public GuideManager() { - guideGroupList = new ArrayList<>(); + guideVersionList = new ArrayList<>(); } public Guide getCurrentGuide() { @@ -30,57 +31,77 @@ public class GuideManager { this.currentGuide = currentGuide; } - public void addGuideGroup(GuideGroup guideGroup) { - this.guideGroupList.add(guideGroup); + public void addGuideGroup(String version, GuideGroup guideGroup) { + GuideVersion guideVersion = getGuideVersion(version); + if (guideVersion == null) { + guideVersion = new GuideVersion(version); + guideVersionList.add(guideVersion); + } + guideVersion.addGuideGroup(guideGroup); } public void addGuide(String groupId, Guide guide) { - for (GuideGroup group : guideGroupList) { - if (StringUtils.equals(groupId, group.getID())) { - group.addGuide(guide); - } + GuideGroup guideGroup = getGuideGroup(groupId); + if (guideGroup != null) { + guideGroup.addGuide(guide); } } - public List getGuideGroupList() { - return guideGroupList; + public List getGuideVersionList() { + return guideVersionList; } public List getAllGuide() { List guideList = new ArrayList<>(); - for (GuideGroup group : getGuideGroupList()) { - for (Guide guide : group.getGuideList()) { - guideList.add(guide); + for (GuideVersion version : guideVersionList) { + for (GuideGroup group : version.getGuideGroupList()) { + for (Guide guide : group.getGuideList()) { + guideList.add(guide); + } } } return guideList; } + public GuideVersion getGuideVersion(String version) { + for (GuideVersion guideVersion : guideVersionList) { + if (StringUtils.equals(version, guideVersion.getVersion())) { + return guideVersion; + } + } + return null; + } + public GuideGroup getGuideGroup(String groupId) { - for (GuideGroup group : getGuideGroupList()) { - if (StringUtils.equals(groupId, group.getID())) { - return group; + for (GuideVersion version : guideVersionList) { + for (GuideGroup group : version.getGuideGroupList()) { + if (StringUtils.equals(groupId, group.getID())) { + return group; + } } } return null; } public Guide getGuide(String guideId) { - for (GuideGroup group : getGuideGroupList()) { - for (Guide guide : group.getGuideList()) { - if (StringUtils.equals(guideId, guide.getID())) { - return guide; + for (GuideVersion version : guideVersionList) { + for (GuideGroup group : version.getGuideGroupList()) { + for (Guide guide : group.getGuideList()) { + if (StringUtils.equals(guideId, guide.getID())) { + return guide; + } } } } - return null; } public void completeAll() { - for (GuideGroup group : getGuideGroupList()) { - for (Guide guide : group.getGuideList()) { - guide.setComplete(true); + for (GuideVersion version : guideVersionList) { + for (GuideGroup group : version.getGuideGroupList()) { + for (Guide guide : group.getGuideList()) { + guide.setComplete(true); + } } } GuideCollector.getInstance().saveInfo(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideVersion.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideVersion.java new file mode 100644 index 0000000000..3c365aa949 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideVersion.java @@ -0,0 +1,29 @@ +package com.fr.design.mainframe.guide.base; + +import java.util.ArrayList; +import java.util.List; + +public class GuideVersion { + private String version; + private List guideGroupList; + public GuideVersion(String version) { + guideGroupList = new ArrayList<>(); + this.version = version; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public List getGuideGroupList() { + return guideGroupList; + } + + public void addGuideGroup(GuideGroup guideGroup) { + guideGroupList.add(guideGroup); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java index eb72c7ebd7..22fbfbd5e9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java @@ -5,18 +5,17 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.guide.scene.AbstractGuideScene; import com.fr.design.mainframe.guide.scene.GuideScene; -import javax.swing.JWindow; +import javax.swing.JDialog; import java.awt.Color; import java.awt.Graphics; import java.awt.Window; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; +import java.awt.event.ComponentListener; import java.awt.event.WindowEvent; import java.awt.event.WindowFocusListener; -public class GuideView extends JWindow{ +public class GuideView extends JDialog { private static GuideView guideView; private Guide invoker; private GuideScene scene; @@ -33,54 +32,43 @@ public class GuideView extends JWindow{ public GuideView(Window window) { super(window); + this.setUndecorated(true); this.window = window; this.modalColor = Color.BLACK; - this.modalOpacity = 0.6f; + this.modalOpacity = 0.4f; this.setPreferredSize(window.getSize()); this.setSize(window.getSize()); this.setLayout(FRGUIPaneFactory.createBorderLayout()); setBg(); - window.addComponentListener(new ComponentAdapter() { - @Override - public void componentResized(ComponentEvent e) { - setLocationRelativeTo(window); - } - - @Override - public void componentMoved(ComponentEvent e) { - setLocation(window.getLocation()); - } - }); - window.addWindowFocusListener(new WindowFocusListener() { - @Override - public void windowGainedFocus(WindowEvent e) { - requestFocus(); - setLocationRelativeTo(window); - } - - @Override - public void windowLostFocus(WindowEvent e) { - - } - }); - this.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (scene == null) { - invoker.terminate(); - } - if (scene instanceof AbstractGuideScene && invoker != null) { - if (((AbstractGuideScene) scene).getHighlightList().size() == 0) { - invoker.terminate(); - } - } - } - }); - } + private WindowFocusListener windowFocusListener = new WindowFocusListener() { + @Override + public void windowGainedFocus(WindowEvent e) { + requestFocus(); + setLocationRelativeTo(window); + } + + @Override + public void windowLostFocus(WindowEvent e) { + + } + }; + + private ComponentListener componentListener = new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + setLocationRelativeTo(window); + } + + @Override + public void componentMoved(ComponentEvent e) { + setLocation(window.getLocation()); + } + }; + public GuideView(Window window, Guide guide) { - this(DesignerContext.getDesignerFrame()); + this(window); this.invoker = guide; } @@ -107,6 +95,8 @@ public class GuideView extends JWindow{ } public void showGuide() { + window.addComponentListener(componentListener); + window.addWindowFocusListener(windowFocusListener); this.setLocationRelativeTo(window); this.setSize(window.getSize()); this.setLocation(window.getLocation()); @@ -119,10 +109,12 @@ public class GuideView extends JWindow{ } public void dismissGuide() { + window.removeComponentListener(componentListener); + window.removeWindowFocusListener(windowFocusListener); this.getLayeredPane().removeAll(); revalidate(); repaint(); - this.setVisible(false); + setVisible(false); } @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java index 4247f2ca2d..9364af6507 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java @@ -14,9 +14,13 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.SwingUtilities; import java.awt.AWTException; +import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Component; +import java.awt.Composite; import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import java.awt.Window; @@ -27,6 +31,9 @@ import java.util.ArrayList; import java.util.List; public abstract class AbstractGuideScene extends JPanel implements GuideScene { + private static final int DEFAULT_ARROW_HEIGHT = 12; + private static final int DEFAULT_ARROW_WIDTH = 18; + private GuideScene nextScene; private SceneFilter sceneFilter; private GuideSceneLifecycle lifecycle; @@ -34,12 +41,15 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { private List targetList; private List highlightList; private Component nextButton; + private List pointsList; + public AbstractGuideScene() { this.setLayout(null); this.setOpaque(false); targetList = new ArrayList<>(); highlightList = new ArrayList<>(); + pointsList = new ArrayList<>(); } /** @@ -65,15 +75,8 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { } else if (component instanceof Window){ Window window = (Window) component; window.toFront(); - window.requestFocus(); image = ScreenImage.createImage(component); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - container.toFront(); - container.requestFocus(); - } - }); + showContainer(); } else { image = captureImage(component); } @@ -82,6 +85,7 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { return true; } catch (AWTException e) { e.printStackTrace(); + GuideManager.getInstance().getCurrentGuide().terminate(); return false; } } @@ -100,6 +104,7 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { return true; } catch (AWTException e) { e.printStackTrace(); + GuideManager.getInstance().getCurrentGuide().terminate(); return false; } } @@ -131,6 +136,7 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { return true; } catch (AWTException e) { e.printStackTrace(); + GuideManager.getInstance().getCurrentGuide().terminate(); return false; } } @@ -184,6 +190,7 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { showContainer(); return image; } + private void showContainer() { SwingUtilities.invokeLater(new Runnable() { @Override @@ -249,6 +256,10 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { this.add(tip.getTip()); } + public void addLineArrow(Point... points) { + pointsList.add(points); + } + public void setContainer(GuideView container) { this.container = container; } @@ -271,6 +282,7 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { @Override public void start() { clear(); + showContainer(); if (lifecycle != null && !lifecycle.prepared()) { return; } @@ -310,26 +322,26 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { public void complete() { container.getLayeredPane().remove(this); container.repaint(); - - if (lifecycle != null) { - lifecycle.onComplete(); - } - if (sceneFilter != null) { - nextScene = sceneFilter.getFilterScene(); - } - if (nextScene != null) { - if (nextScene instanceof AbstractGuideScene) { - ((AbstractGuideScene) nextScene).setContainer(container); - } - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (lifecycle != null) { + lifecycle.onComplete(); + } + if (sceneFilter != null) { + nextScene = sceneFilter.getFilterScene(); + } + if (nextScene != null) { + if (nextScene instanceof AbstractGuideScene) { + ((AbstractGuideScene) nextScene).setContainer(container); + } nextScene.start(); + } else { + GuideManager.getInstance().getCurrentGuide().complete(); } - }); - } else { - GuideManager.getInstance().getCurrentGuide().complete(); - } + + } + }); } @Override @@ -383,4 +395,87 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { invalidate(); repaint(); } + + @Override + public void paint(Graphics g) { + super.paint(g); + if (pointsList.isEmpty()) { + return; + } + Graphics2D g2d = (Graphics2D) g; + Composite oldComposite = g2d.getComposite(); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); + g2d.setColor(Color.WHITE); + for (Point[] points : pointsList) { + if (points.length <= 1) { + continue; + } + Point startPoint = points[0]; + Point endPoint = startPoint; + for (int index = 1; index < points.length; index++) { + startPoint = endPoint; + endPoint = points[index]; + g2d.drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y); + } + + drawArrow(g2d, startPoint, endPoint); + } + g2d.setComposite(oldComposite); + } + + /** + * 根据最后两点坐标计算出三角箭头的三个点坐标,绘制箭头 + * 这里实现以终点坐标为坐标轴圆点计算 + * @param start 起始点坐标 + * @param end 重点坐标 + */ + private void drawArrow(Graphics2D g2d, Point start, Point end) { + try{ + double dealtPointX = start.x - end.x; + double dealtPointY = -(start.y - end.y); + + double pointDistance = calDistance(dealtPointX, dealtPointY); + double triangleHeight = Math.min(DEFAULT_ARROW_HEIGHT, pointDistance); + double triangleWidth = triangleHeight * (DEFAULT_ARROW_WIDTH / 2) / DEFAULT_ARROW_WIDTH; + if (triangleHeight < 1 || triangleWidth < 1 || pointDistance < 1) { + return; + } + + double pointAngle; + double abs = 1; + if (dealtPointX == 0) { + pointAngle = Math.PI / 2; + } else { + pointAngle = Math.atan(dealtPointY / dealtPointX); + } + if (dealtPointY < 0) { + pointAngle += Math.PI; + abs = -1; + } + + double deltaAngle = Math.atan(triangleWidth / triangleHeight); + double triangleDistance = calDistance(triangleWidth, triangleHeight); + + Point p1 =calPoint(end, triangleDistance, pointAngle - deltaAngle, abs); + Point p2 = calPoint(end, triangleDistance, pointAngle + deltaAngle, abs); + + int xPoints[] = {end.x, p1.x, p2.x}; + int yPoints[] = {end.y, p1.y, p2.y}; + + g2d.fillPolygon(xPoints, yPoints, 3); + } catch (Exception e) { + e.printStackTrace(); + GuideManager.getInstance().getCurrentGuide().terminate(); + } + } + + private double calDistance(double x, double y) { + return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)); + } + + private Point calPoint(Point relativePoint, double distance, double angle, double abs) { + int x = (int)(relativePoint.x + abs * distance * Math.cos(angle)); + int y = (int)(relativePoint.y - abs * distance * Math.sin(angle)); + return new Point(x, y); + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/ClickScene.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/ClickScene.java index 6b0f4b0d5b..234783fa4c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/ClickScene.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/ClickScene.java @@ -1,5 +1,7 @@ package com.fr.design.mainframe.guide.scene; +import com.fr.design.mainframe.guide.base.GuideManager; + import java.awt.Component; import java.awt.Point; import java.awt.Rectangle; @@ -87,4 +89,13 @@ public class ClickScene extends AbstractGuideScene{ .getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger())); } + + @Override + public void showScene() { + super.showScene(); + // 交互类的 scene 如果没有高亮内容块载,需要及时终止Guide,否则就没法去掉模态框影响到设计器主功能的使用了 + if (this.getComponentCount() == 0) { + GuideManager.getInstance().getCurrentGuide().terminate(); + } + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/tip/BubbleTip.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/tip/BubbleTip.java index 7d954150ff..1d56fa534f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/tip/BubbleTip.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/tip/BubbleTip.java @@ -1,11 +1,16 @@ package com.fr.design.mainframe.guide.tip; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.guide.base.Guide; import com.fr.design.mainframe.guide.base.GuideManager; import com.fr.design.mainframe.guide.ui.bubble.Bubble; import com.fr.design.mainframe.guide.ui.bubble.BubbleWithClose; import javax.swing.JComponent; +import javax.swing.JOptionPane; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -28,7 +33,16 @@ public class BubbleTip implements GuideTip { public void actionPerformed(ActionEvent e) { Guide currentGuide = GuideManager.getInstance().getCurrentGuide(); if (currentGuide != null) { - currentGuide.terminate(); + + int returnVal = FineJOptionPane.showConfirmDialog( + currentGuide.getGuideView(), + "确认退出当前教学引导?", + Toolkit.i18nText("Fine-Design_Basic_Confirm"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + if (returnVal == JOptionPane.YES_OPTION) { + currentGuide.terminate(); + } } } }); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java index 8d529f33b8..15d14df9b8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java @@ -46,6 +46,7 @@ public class GuideCompleteDialog extends JDialog { super(window); setSize(DIALOG_WIDTH, DIALOG_HEIGHT); setUndecorated(true); + setModal(true); setLocationRelativeTo(window); this.setContentPane(getContentPane()); } @@ -94,7 +95,6 @@ public class GuideCompleteDialog extends JDialog { public void actionPerformed(ActionEvent e) { setVisible(false); dispose(); - GuideManageDialog.getInstance().showDialog(); } }); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideManageDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideManageDialog.java index 3f25d13084..07059ad052 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideManageDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideManageDialog.java @@ -11,6 +11,7 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.guide.base.Guide; import com.fr.design.mainframe.guide.base.GuideGroup; import com.fr.design.mainframe.guide.base.GuideManager; +import com.fr.design.mainframe.guide.base.GuideVersion; import com.fr.design.mainframe.guide.collect.GuideCollector; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.IOUtils; @@ -56,6 +57,7 @@ public class GuideManageDialog extends JDialog { private void initComponent() { this.setTitle(Toolkit.i18nText("Fine-Design_Guide_Manager_Dialog_Title")); setResizable(false); + setModal(true); setLayout(FRGUIPaneFactory.createBorderLayout()); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); GUICoreUtils.centerWindow(this); @@ -71,6 +73,15 @@ public class GuideManageDialog extends JDialog { return scrollPane; } + private JPanel createGuideVersionPane(GuideVersion guideVersion) { + JPanel expandContent = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, VerticalFlowLayout.TOP, 0, 5); + for (GuideGroup guideGroup : guideVersion.getGuideGroupList()) { + JPanel guideGroupCard = createGuideGroupCard(guideGroup); + expandContent.add(guideGroupCard); + } + ExpandPane expandPane = new ExpandPane(Toolkit.i18nText("Fine-Design_Guide_Manager_Dialog_Version_Title", guideVersion.getVersion()), expandContent); + return expandPane; + } private JPanel createGuideGroupCard(GuideGroup guideGroup) { @@ -213,13 +224,9 @@ public class GuideManageDialog extends JDialog { private void resetScrollContent() { scrollContent.removeAll(); - JPanel expandContent = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, VerticalFlowLayout.TOP, 0, 5); - for (GuideGroup guideGroup : GuideManager.getInstance().getGuideGroupList()) { - JPanel guideGroupCard = createGuideGroupCard(guideGroup); - expandContent.add(guideGroupCard); + for (GuideVersion guideVersion : GuideManager.getInstance().getGuideVersionList()) { + scrollContent.add(createGuideVersionPane(guideVersion)); } - ExpandPane expandPane = new ExpandPane(Toolkit.i18nText("Fine-Design_Guide_Manager_Dialog_Version_Title", "11.0.0"), expandContent); - scrollContent.add(expandPane); revalidate(); repaint(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/utils/ScreenImage.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/utils/ScreenImage.java index 7c722d7de5..3d718ec1cf 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/utils/ScreenImage.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/utils/ScreenImage.java @@ -61,7 +61,7 @@ public class ScreenImage { BufferedImage image = new BufferedImage(region.width, region.height, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = image.createGraphics(); g2d.drawImage(createImage(component), 0, 0, null); - g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f)); g2d.setColor(Color.BLACK); g2d.fillRect(0, 0, region.width, region.height); g2d.dispose(); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java index a1869ed795..7e5e40ef9f 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/NewFormPane.java @@ -69,9 +69,7 @@ public class NewFormPane extends BasicPane { dialog.addDialogActionListener(new DialogActionListener() { @Override public void doOk() { - if (selectedLayoutPane != null) { - NewFormPane.this.newForm(selectedLayoutPane.getTemplatePath()); - } + createLayoutForm(); } @Override @@ -85,6 +83,12 @@ public class NewFormPane extends BasicPane { dialog.setResizable(false); } + public void createLayoutForm() { + if (selectedLayoutPane != null) { + NewFormPane.this.newForm(selectedLayoutPane.getTemplatePath()); + } + } + @Override protected String title4PopupWindow() { return Toolkit.i18nText("Fine-Design_New_Template"); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/GuideIds.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/GuideIds.java index 29210c5ddb..efb9a74049 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/GuideIds.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/GuideIds.java @@ -1,6 +1,10 @@ package com.fr.design.mainframe.guide; public class GuideIds { + public static class GuideVersion { + public static final String V11_0_0 = "11.0.0"; + } + public static class GuideGroup { public static final String F01 = "F01"; public static final String F02 = "F02"; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/GuideRegister.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/GuideRegister.java index deafa66fab..8ed6f3a30f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/GuideRegister.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/GuideRegister.java @@ -17,8 +17,8 @@ public class GuideRegister { } private static void registerGroup() { - GuideManager.getInstance().addGuideGroup(new GuideGroup(GuideIds.GuideGroup.F01, Toolkit.i18nText("Fine-Design_Guide_Group_F01_Name"))); - GuideManager.getInstance().addGuideGroup(new GuideGroup(GuideIds.GuideGroup.F02, Toolkit.i18nText("Fine-Design_Guide_Group_F02_Name"))); + GuideManager.getInstance().addGuideGroup(GuideIds.GuideVersion.V11_0_0, new GuideGroup(GuideIds.GuideGroup.F01, Toolkit.i18nText("Fine-Design_Guide_Group_F01_Name"))); + GuideManager.getInstance().addGuideGroup(GuideIds.GuideVersion.V11_0_0, new GuideGroup(GuideIds.GuideGroup.F02, Toolkit.i18nText("Fine-Design_Guide_Group_F02_Name"))); } private static void registerGuide() { 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 f39683b718..d38db10b5d 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 @@ -145,7 +145,7 @@ public class UseLayoutAndComponentGuide { public boolean prepared() { Component component = ComponentUtils.findComponentByName(newFormPane.getWindow().getContentPane(), UIDialog.OK_BUTTON); if (component != null) { - scene.addClickTarget(component, ClickScene.ClickType.LEFT, true); + scene.addClickTarget(component, ClickScene.ClickType.LEFT); scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Tip_Click_Confirm"), GuideTip.Direction.TOP); } return super.prepared(); @@ -153,6 +153,7 @@ public class UseLayoutAndComponentGuide { @Override public void onComplete() { + newFormPane.createLayoutForm(); newFormPane.getWindow().dispose(); } }); 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 a0b72ec5c2..0fa69aa05c 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 @@ -53,8 +53,10 @@ public class ThemeToggleGuide { scene1.nextScene(createScene2()) .nextScene(createScene3()) .nextScene(createScene4()) + .nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene()) .nextScene(createScene5()) .nextScene(createScene6()) + .nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene()) .nextScene(GuideSceneHelper.createPreviewClickScene()); Guide guide = GuideBuilder.newInstance() @@ -115,11 +117,6 @@ public class ThemeToggleGuide { return true; } - public void onShow() { - GuideManager.getInstance().getCurrentGuide().getGuideView().toFront(); // brings to front without needing to setAlwaysOnTop - GuideManager.getInstance().getCurrentGuide().getGuideView().requestFocus(); - } - @Override public void onComplete() { @@ -164,22 +161,23 @@ public class ThemeToggleGuide { } private static GuideScene createScene5() { - DisplayScene scene = new DisplayScene(); + ClickScene scene = new ClickScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override public boolean prepared() { - JForm jForm = (JForm) DesignerContext.getDesignerFrame().getSelectedJTemplate(); - scene.addTarget(jForm.getFormDesign()); - return true; + XCreator xCreator = GuideCreateUtils.getXCreatorFormDesigner("chart00"); + scene.addClickTarget(GuideCreateUtils.getFormDesigner(), GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(xCreator), ClickScene.ClickType.LEFT); + scene.addBubbleTip("选择此模板", BubbleTip.Direction.BOTTOM); + return super.prepared(); } @Override - public void onShow() { - JForm jForm = (JForm) DesignerContext.getDesignerFrame().getSelectedJTemplate(); - FormDesigner designer = jForm.getFormDesign(); - XCreator xCreator = (XCreator) designer.getRootComponent().getComponent(0); - jForm.getFormDesign().getSelectionModel().reset(); - jForm.getFormDesign().getSelectionModel().selectACreator(xCreator); + public void onComplete() { + super.onComplete(); + FormDesigner designer = GuideCreateUtils.getFormDesigner(); + XCreator xCreator = GuideCreateUtils.getXCreatorFormDesigner("chart00"); + designer.getSelectionModel().reset(); + designer.getSelectionModel().selectACreator(xCreator); } }); return scene; @@ -191,26 +189,27 @@ public class ThemeToggleGuide { scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override public boolean prepared() { - JForm jForm = (JForm) DesignerContext.getDesignerFrame().getSelectedJTemplate(); - FormDesigner designer = jForm.getFormDesign(); - XCreator xCreator = (XCreator) designer.getRootComponent().getComponent(0); - scene.addTarget(designer, GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(xCreator)); - - Component target2 = ComponentUtils.findComponentByClass(EastRegionContainerPane.getInstance(), FollowingThemePane.class); - target2 = ComponentUtils.findComponentByClass(target2, UIButtonGroup.class); - if (target2 != null) { - uiButtonGroup[0] = (UIButtonGroup) target2; - target2 = ((UIButtonGroup) target2).getButton(0); - scene.addClickTarget(target2, ClickScene.ClickType.LEFT); - scene.addBubbleTip( - Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Tip_Toggle_Follow_Theme"), - Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Tip_Toggle_Follow_Theme_Description"), - GuideTip.Direction.BOTTOM, - 0.5f, - 0.8f - ); - } - return true; + new Timer().schedule(new TimerTask() { + @Override + public void run() { + Component target2 = ComponentUtils.findComponentByClass(EastRegionContainerPane.getInstance(), FollowingThemePane.class); + target2 = ComponentUtils.findComponentByClass(target2, UIButtonGroup.class); + if (target2 != null) { + uiButtonGroup[0] = (UIButtonGroup) target2; + target2 = ((UIButtonGroup) target2).getButton(0); + scene.addClickTarget(target2, ClickScene.ClickType.LEFT); + scene.addBubbleTip( + Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Tip_Toggle_Follow_Theme"), + Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Tip_Toggle_Follow_Theme_Description"), + GuideTip.Direction.BOTTOM, + 0.5f, + 0.8f + ); + scene.showScene(); + } + } + },1000); + return false; } @Override @@ -232,6 +231,5 @@ public class ThemeToggleGuide { if (!themeDialog.isVisible()) { themeDialog.setVisible(true); } - themeDialog.requestFocus(); } }