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 9469f931a1..c8d3e6801d 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 @@ -10,6 +10,8 @@ import com.fr.stable.StringUtils; import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; public class Guide { private String id; @@ -101,7 +103,7 @@ public class Guide { } GuideManager.getInstance().setCurrentGuide(this); guideView.showLoading(); - + guideView.addHierarchyListener(loadingHierarchyListener); new SwingWorker() { @Override protected Boolean doInBackground() { @@ -135,6 +137,9 @@ public class Guide { public void start() { guideView.hideLoading(); + } + + private void startScene() { if (scene != null) { guideView.setScene(scene); guideView.showGuide(); @@ -161,6 +166,7 @@ public class Guide { if (lifecycle != null) { lifecycle.onTerminate(); } + guideView.removeHierarchyListener(loadingHierarchyListener); end(); } @@ -186,4 +192,12 @@ public class Guide { public void removeGuideLifecycle() { this.lifecycle = null; } + + private HierarchyListener loadingHierarchyListener = new HierarchyListener() { + @Override + public void hierarchyChanged(HierarchyEvent e) { + guideView.removeHierarchyListener(loadingHierarchyListener); + startScene(); + } + }; } 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 5ead71c621..cdb1765ffb 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 @@ -13,6 +13,7 @@ import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.JPopupMenu; import javax.swing.SwingUtilities; import java.awt.AWTException; import java.awt.AlphaComposite; @@ -75,13 +76,16 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { if (component instanceof JComponent) { JComponent jComponent = (JComponent) component; image = ScreenImage.createImage(jComponent); + highlightList.add(getTargetComponentWithImage(image, rectangle, !(component.getParent() instanceof JPopupMenu))); } else if (component instanceof Window) { image = ScreenImage.createImage(component); + highlightList.add(getTargetComponentWithImage(image, rectangle, false)); } else { image = captureImage(component); + highlightList.add(getTargetComponentWithImage(image, rectangle,true)); } targetList.add(component); - highlightList.add(getTargetComponentWithImage(image, rectangle)); + return true; } catch (AWTException e) { e.printStackTrace(); @@ -99,7 +103,7 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { try { targetList.add(null); BufferedImage image = captureImage(rectangle); - highlightList.add(getTargetComponentWithImage(image, rectangle)); + highlightList.add(getTargetComponentWithImage(image, rectangle, true)); return true; } catch (AWTException e) { e.printStackTrace(); @@ -133,7 +137,7 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { image = ScreenImage.createImage(component).getSubimage(origin.x, origin.y, origin.width, origin.height); } targetList.add(component); - highlightList.add(getTargetComponentWithImage(image, rectangle)); + highlightList.add(getTargetComponentWithImage(image, rectangle, true)); return true; } catch (AWTException e) { e.printStackTrace(); @@ -170,22 +174,29 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { return highlightList; } - private UILabel getTargetComponentWithImage(BufferedImage image, Rectangle rectangle) { + private UILabel getTargetComponentWithImage(BufferedImage image, Rectangle rectangle, boolean showBorder) { ImageIcon ic = new ImageIcon(image); - UILabel label = new UILabel(ic){ - @Override - public Insets getInsets() { - return DEFAULT_HIGHLIGHT_INSETS; - } - }; - label.setBackground(Color.WHITE); - label.setOpaque(true); - label.setBounds(new Rectangle( - rectangle.x - DEFAULT_HIGHLIGHT_INSETS.left, - rectangle.y - DEFAULT_HIGHLIGHT_INSETS.top, - rectangle.width + DEFAULT_HIGHLIGHT_INSETS.left + DEFAULT_HIGHLIGHT_INSETS.right, - rectangle.height + DEFAULT_HIGHLIGHT_INSETS.top + DEFAULT_HIGHLIGHT_INSETS.bottom - )); + UILabel label; + if (showBorder) { + label = new UILabel(ic){ + @Override + public Insets getInsets() { + return DEFAULT_HIGHLIGHT_INSETS; + } + }; + label.setBackground(Color.WHITE); + label.setOpaque(true); + label.setBounds(new Rectangle( + rectangle.x - DEFAULT_HIGHLIGHT_INSETS.left, + rectangle.y - DEFAULT_HIGHLIGHT_INSETS.top, + rectangle.width + DEFAULT_HIGHLIGHT_INSETS.left + DEFAULT_HIGHLIGHT_INSETS.right, + rectangle.height + DEFAULT_HIGHLIGHT_INSETS.top + DEFAULT_HIGHLIGHT_INSETS.bottom + )); + } else { + label = new UILabel(ic); + label.setBounds(rectangle); + } + return label; }