kuangshuai
3 years ago
3 changed files with 64 additions and 53 deletions
@ -1,47 +0,0 @@ |
|||||||
package com.fr.design.mainframe.guide.ui; |
|
||||||
|
|
||||||
import com.fr.design.mainframe.DesignerContext; |
|
||||||
import com.fr.design.mainframe.DesignerFrame; |
|
||||||
import com.fr.design.mainframe.guide.collect.GuideCollector; |
|
||||||
|
|
||||||
import javax.swing.JDialog; |
|
||||||
import java.awt.Color; |
|
||||||
import java.awt.Point; |
|
||||||
import java.awt.Window; |
|
||||||
import java.awt.event.ActionEvent; |
|
||||||
import java.awt.event.ActionListener; |
|
||||||
|
|
||||||
public class BubbleHintDialog extends JDialog { |
|
||||||
private static final int DIALOG_WIDTH = 220; |
|
||||||
private static final int DIALOG_HEIGHT = 140; |
|
||||||
private static BubbleHintDialog dialog; |
|
||||||
|
|
||||||
public static BubbleHintDialog getInstance(){ |
|
||||||
if (dialog == null) { |
|
||||||
dialog = new BubbleHintDialog(DesignerContext.getDesignerFrame()); |
|
||||||
} |
|
||||||
return dialog; |
|
||||||
} |
|
||||||
|
|
||||||
public BubbleHintDialog(Window parent) { |
|
||||||
super(parent); |
|
||||||
setUndecorated(true); |
|
||||||
this.setBackground(new Color(0,0,0,0)); |
|
||||||
setSize(DIALOG_WIDTH, DIALOG_HEIGHT); |
|
||||||
BubbleHint bubbleHint = new BubbleHint(); |
|
||||||
bubbleHint.addConfirmAction(new ActionListener() { |
|
||||||
@Override |
|
||||||
public void actionPerformed(ActionEvent e) { |
|
||||||
setVisible(false); |
|
||||||
dispose(); |
|
||||||
GuideCollector.getInstance().setShowHint(true); |
|
||||||
} |
|
||||||
}); |
|
||||||
this.setContentPane(bubbleHint); |
|
||||||
} |
|
||||||
|
|
||||||
public void showDialog(Point location) { |
|
||||||
dialog.setLocation(location); |
|
||||||
dialog.setVisible(true); |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,63 @@ |
|||||||
|
package com.fr.design.mainframe.guide.entry; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.mainframe.guide.base.GuideView; |
||||||
|
import com.fr.design.mainframe.guide.collect.GuideCollector; |
||||||
|
import com.fr.design.mainframe.guide.scene.AbstractGuideScene; |
||||||
|
import com.fr.design.mainframe.guide.scene.GuideSceneLifecycleAdaptor; |
||||||
|
import com.fr.design.mainframe.guide.ui.BubbleHint; |
||||||
|
|
||||||
|
import javax.swing.SwingUtilities; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.Point; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
public class GuideEntryHint { |
||||||
|
private static GuideEntryHint hint; |
||||||
|
private GuideView guideView; |
||||||
|
|
||||||
|
public static GuideEntryHint getInstance() { |
||||||
|
if (hint == null) { |
||||||
|
hint = new GuideEntryHint(); |
||||||
|
} |
||||||
|
return hint; |
||||||
|
} |
||||||
|
|
||||||
|
public GuideEntryHint() { |
||||||
|
AbstractGuideScene scene = new AbstractGuideScene(){}; |
||||||
|
BubbleHint bubbleHint = new BubbleHint(); |
||||||
|
guideView = new GuideView(DesignerContext.getDesignerFrame()); |
||||||
|
|
||||||
|
bubbleHint.addConfirmAction(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
GuideCollector.getInstance().setShowHint(true); |
||||||
|
guideView.dismissGuide(); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||||
|
@Override |
||||||
|
public boolean prepared() { |
||||||
|
scene.addTarget(GuideEntryPane.getGuideEntryPane()); |
||||||
|
scene.addCustomTarget(bubbleHint, getBubbleLocation()); |
||||||
|
return true; |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
guideView.setScene(scene); |
||||||
|
} |
||||||
|
|
||||||
|
public void show() { |
||||||
|
if (!guideView.isVisible()) { |
||||||
|
guideView.showGuide(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private Point getBubbleLocation() { |
||||||
|
Point point = SwingUtilities.convertPoint(GuideEntryPane.getGuideEntryPane(),0,0, guideView.getRootPane()); |
||||||
|
Dimension size = GuideEntryPane.getGuideEntryPane().getSize(); |
||||||
|
return new Point(point.x - 187,point.y + size.height); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue