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 5f5747c59..9aa0bb5f1 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 @@ -15,6 +15,7 @@ public class Guide { private String id; private String name; private String description; + private String completeMessage; private GuideState state; private GuideView guideView; private GuideLifecycle lifecycle; @@ -32,7 +33,7 @@ public class Guide { this.state = GuideState.NONE; } - public String getID() { + public String getId() { return id; } @@ -59,6 +60,14 @@ public class Guide { return name; } + public String getCompleteMessage() { + return completeMessage; + } + + public void setCompleteMessage(String completeMessage) { + this.completeMessage = completeMessage; + } + public GuideState getState() { return state; } @@ -137,7 +146,7 @@ public class Guide { setComplete(true); GuideCollector.getInstance().saveInfo(); guideView.dismissGuide(); - GuideCompleteDialog.getInstance().showDialog(getName()); + GuideCompleteDialog.getInstance().showDialog(getCompleteMessage()); end(); } @@ -149,11 +158,11 @@ public class Guide { } public void end() { - GuideManager.getInstance().setCurrentGuide(null); guideView.dismissGuide(); if (lifecycle != null) { lifecycle.onEnd(); } + GuideManager.getInstance().setCurrentGuide(null); GuideManageDialog.getInstance().showDialog(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideBuilder.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideBuilder.java index 51aa82118..a1974bf92 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideBuilder.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideBuilder.java @@ -30,6 +30,11 @@ public class GuideBuilder { return this; } + public GuideBuilder setCompleteMessage(String message) { + guide.setCompleteMessage(message); + return this; + } + public GuideBuilder addScene(GuideScene scene) { guide.setScene(scene); return this; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideGroup.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideGroup.java index 25310fb57..cd5e0b579 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideGroup.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideGroup.java @@ -14,10 +14,14 @@ public class GuideGroup { guideList = new ArrayList<>(); } - public String getID() { + public String getId() { return id; } + public void setId(String id) { + this.id = id; + } + public String getName() { return name; } 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 b14cae486..e5d837b59 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 @@ -75,7 +75,7 @@ public class GuideManager { public GuideGroup getGuideGroup(String groupId) { for (GuideVersion version : guideVersionList) { for (GuideGroup group : version.getGuideGroupList()) { - if (StringUtils.equals(groupId, group.getID())) { + if (StringUtils.equals(groupId, group.getId())) { return group; } } @@ -87,7 +87,7 @@ public class GuideManager { for (GuideVersion version : guideVersionList) { for (GuideGroup group : version.getGuideGroupList()) { for (Guide guide : group.getGuideList()) { - if (StringUtils.equals(guideId, guide.getID())) { + if (StringUtils.equals(guideId, guide.getId())) { return guide; } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/collect/GuideCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/collect/GuideCollector.java index b1d85761c..4c4c40f76 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/collect/GuideCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/collect/GuideCollector.java @@ -55,7 +55,7 @@ public class GuideCollector implements XMLable { public void load() { for(Guide cacheGuide : cacheGuides) { - Guide guide = GuideManager.getInstance().getGuide(cacheGuide.getID()); + Guide guide = GuideManager.getInstance().getGuide(cacheGuide.getId()); if (guide != null) { guide.setComplete(cacheGuide.isComplete()); } @@ -139,7 +139,7 @@ public class GuideCollector implements XMLable { writer.attr("showHint", showHint); for(Guide guide : GuideManager.getInstance().getAllGuide()) { writer.startTAG(GUIDE_XML); - writer.attr("id", guide.getID()); + writer.attr("id", guide.getId()); writer.attr("isComplete", guide.isComplete()); writer.end(); } 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 e3f844c5f..4f16cbe75 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 @@ -72,9 +72,10 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { if (component instanceof JComponent) { JComponent jComponent = (JComponent) component; image = ScreenImage.createImage(jComponent); + } else if (component instanceof Window) { + image = ScreenImage.createImage(component); } else { image = captureImage(component); - showContainer(); } targetList.add(component); highlightList.add(getTargetComponentWithImage(image, rectangle)); @@ -208,7 +209,7 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { * @param anchor 气泡窗口箭头坐标 * @param bubbleTailStart 气泡窗口箭头坐标相对于位置方向交叉轴的比例(从左到右,从上到下) */ - public void addBubbleTip(String title,String content, GuideTip.Direction direction, Point anchor, float bubbleTailStart) { + public void addBubbleTip(String title, String content, GuideTip.Direction direction, Point anchor, float bubbleTailStart) { BubbleTip bt = new BubbleTip(title, content, direction, bubbleTailStart); bt.setAnchor(anchor); this.add(bt.getTip()); @@ -279,66 +280,68 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene { @Override public void start() { clear(); - showContainer(); if (lifecycle != null && !lifecycle.prepared()) { return; } - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - showScene(); - } - }); + showScene(); } @Override public void showScene() { - if (container != null) { - container.setContentPane(this); - this.setBounds(0, 0 , getSceneWidth(), getSceneWidth()); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (container != null) { + container.setContentPane(AbstractGuideScene.this); + setBounds(0, 0 , getSceneWidth(), getSceneWidth()); - // show target - for (int index = highlightList.size() - 1; index >= 0; index--) { - this.add(highlightList.get(index)); - } - // show next button - if (nextButton != null) { - nextButton.setBounds((getSceneWidth() - 60) / 2, getSceneHeight() - 100, 60, 30); - this.add(nextButton); - } + // show target + for (int index = highlightList.size() - 1; index >= 0; index--) { + add(highlightList.get(index)); + } + // show next button + if (nextButton != null) { + nextButton.setBounds((getSceneWidth() - 60) / 2, getSceneHeight() - 100, 60, 30); + add(nextButton); + } - container.revalidate(); - container.repaint(); - } - if (lifecycle != null) { - lifecycle.onShow(); - } + container.revalidate(); + container.repaint(); + } + showContainer(); + if (lifecycle != null) { + lifecycle.onShow(); + } + } + }); } @Override public void complete() { container.getLayeredPane().remove(this); container.repaint(); - 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); - } + 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() { nextScene.start(); - } else { - GuideManager.getInstance().getCurrentGuide().complete(); } + }); + } else { + GuideManager.getInstance().getCurrentGuide().complete(); + } + + - } - }); } @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/DisplayScene.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/DisplayScene.java index 1c44012d1..21ebe972d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/DisplayScene.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/scene/DisplayScene.java @@ -6,6 +6,7 @@ import java.util.TimerTask; public class DisplayScene extends AbstractGuideScene { private long delay; private static final long DEFAULT_DELAY = 1000; + private static Timer displayTimer = new Timer(); public DisplayScene() { this(DEFAULT_DELAY); @@ -24,10 +25,13 @@ public class DisplayScene extends AbstractGuideScene { public void showScene() { super.showScene(); // 实例化Timer类 - new Timer().schedule(new TimerTask() { + displayTimer.schedule(new TimerTask() { + @Override public void run() { complete(); + displayTimer.purge(); } }, delay); } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/BubbleHintDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/BubbleHintDialog.java index 6e67114af..5a7b55c81 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/BubbleHintDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/guide/ui/BubbleHintDialog.java @@ -1,9 +1,12 @@ 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; @@ -11,6 +14,15 @@ 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); @@ -27,4 +39,9 @@ public class BubbleHintDialog extends JDialog { }); this.setContentPane(bubbleHint); } + + public void showDialog(Point location) { + dialog.setLocation(location); + dialog.setVisible(true); + } } 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 15d14df9b..0b060d546 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 @@ -110,7 +110,7 @@ public class GuideCompleteDialog extends JDialog { } public void showDialog(String str) { - textArea.setText(Toolkit.i18nText("Fine-Design_Guide_Complete_Hint", str)); + textArea.setText(str); repaint(); this.setVisible(true); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/GroupPane.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/GroupPane.java index 05507a786..1e9ca55a1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/GroupPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/GroupPane.java @@ -40,7 +40,7 @@ import java.util.List; * @Author: Yuan.Wang * @Date: 2020/11/5 */ -class GroupPane extends JPanel { +public class GroupPane extends JPanel { private static final Icon downIcon = IOUtils.readIcon("/com/fr/base/images/share/arrow_down.png"); private static final Icon rightIcon = IOUtils.readIcon("/com/fr/base/images/share/arrow_right.png"); private static final int DEFAULT_HEIGHT = 24; diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/InstallComponentHelper.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/InstallComponentHelper.java index 437997e03..b66c2458c 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/util/InstallComponentHelper.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/InstallComponentHelper.java @@ -21,7 +21,7 @@ import java.io.InputStream; public class InstallComponentHelper { private static final String PRE_INSTALL_PATH = "/com/fr/form/share/components"; - public static final String[] PRE_INSTALL_COMPONENTS = new String[]{ + private static final String[] PRE_INSTALL_COMPONENTS = new String[]{ "单行指标卡.f3df58b3-4302-4cab-ab77-caaf225de60a.reu", "分层雷达图-深色.49f8397c-e6a6-482a-acc7-46d8cec353a4.reu", "红绿灯表格-浅色.d0466992-328a-4ccf-ad67-6cbc844d669c.reu", @@ -32,34 +32,21 @@ public class InstallComponentHelper { public static void installPreComponent() { if (needPreInstallComponent()) { - for (String componentPath : PRE_INSTALL_COMPONENTS) { - try { - InputStream inputStream = InstallComponentHelper.class.getResourceAsStream(StableUtils.pathJoin(PRE_INSTALL_PATH, componentPath)); - byte[] data = ResourceIOUtils.inputStream2Bytes(inputStream); - WorkContext.getWorkResource().write(StableUtils.pathJoin(ComponentPath.SHARE_PATH.path(), componentPath), data); - } catch (Exception e) { - FineLoggerFactory.getLogger().error("install Component filed" + e.getMessage(), e); - } - } + installShareComponents(PRE_INSTALL_PATH, PRE_INSTALL_COMPONENTS); } } - public static String[] installPreComponent(int count) { - count = Math.max(Math.min(count, PRE_INSTALL_COMPONENTS.length), 0); - String[] installNames = new String[count]; - for (int index = 0; index < count; index ++) { + public static void installShareComponents(String resourcePath, String[] components) { + for (String componentPath : components) { try { - String componentPath = PRE_INSTALL_COMPONENTS[index]; - InputStream inputStream = InstallComponentHelper.class.getResourceAsStream(StableUtils.pathJoin(PRE_INSTALL_PATH, componentPath)); + InputStream inputStream = InstallComponentHelper.class.getResourceAsStream(StableUtils.pathJoin(resourcePath, componentPath)); byte[] data = ResourceIOUtils.inputStream2Bytes(inputStream); WorkContext.getWorkResource().write(StableUtils.pathJoin(ComponentPath.SHARE_PATH.path(), componentPath), data); - installNames[index] = componentPath; } catch (Exception e) { FineLoggerFactory.getLogger().error("install Component filed" + e.getMessage(), e); } } - return installNames; } private static boolean needPreInstallComponent() { 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 d19d20b8a..3abb1db14 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 @@ -21,15 +21,18 @@ import com.fr.workspace.WorkContext; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JDialog; -import javax.swing.JPopupMenu; import javax.swing.SwingUtilities; import java.awt.Component; import java.awt.Point; import java.awt.Rectangle; import java.io.InputStream; +import java.util.Timer; import java.util.UUID; public class GuideCreateUtils { + private static final String FILE_PREFIX = "Guide_"; + public static Timer TIMER = new Timer(); + public static FormDesigner getFormDesigner() { JForm jForm = (JForm) DesignerContext.getDesignerFrame().getSelectedJTemplate(); FormDesigner designer = jForm.getFormDesign(); @@ -39,9 +42,37 @@ public class GuideCreateUtils { public static Rectangle getXCreatorBoundsRelative2FormDesigner(XCreator xCreator) { FormDesigner designer = getFormDesigner(); Point point = SwingUtilities.convertPoint(xCreator, 0, 0, designer.getRootComponent()); + Rectangle bounds = new Rectangle(point.x + designer.getPaintX() - designer.getHorizontalScaleValue(), point.y + designer.getPaintY(), xCreator.getWidth(), xCreator.getHeight()); + bounds.intersection(new Rectangle(point.x, point.y, designer.getWidth(), designer.getHeight())); + return bounds; + } + + public static Rectangle getXCreatorBoundsRelative2FormDesigner(String widgetName) { + FormDesigner designer = getFormDesigner(); + XCreator xCreator = getXCreatorFormDesigner(widgetName); + if (xCreator == null) { + return new Rectangle(0,0,0,0); + } + Point point = SwingUtilities.convertPoint(getXCreatorFormDesigner(widgetName), 0, 0, designer.getRootComponent()); return new Rectangle(point.x + designer.getPaintX() - designer.getHorizontalScaleValue(), point.y + designer.getPaintY(), xCreator.getWidth(), xCreator.getHeight()); } + public static Rectangle getXCreatorBoundsRelative2GuideView(String widgetName) { + XCreator xCreator = getXCreatorFormDesigner(widgetName); + Point designerLocationToGuideView = SwingUtilities.convertPoint(getFormDesigner(),0,0, GuideManager.getInstance().getCurrentGuide().getGuideView().getRootPane()); + if (xCreator == null) { + return new Rectangle(designerLocationToGuideView.x, designerLocationToGuideView.y ,0,0); + } + Rectangle boundsRelative2Designer = getXCreatorBoundsRelative2FormDesigner(xCreator); + return new Rectangle( + designerLocationToGuideView.x + boundsRelative2Designer.x, + designerLocationToGuideView.y + boundsRelative2Designer.y, + boundsRelative2Designer.width, + boundsRelative2Designer.height + ); + + } + public static XCreator getXCreatorFormDesigner(String name) { FormDesigner designer = getFormDesigner(); XLayoutContainer rootComponent = designer.getRootComponent(); @@ -49,6 +80,13 @@ public class GuideCreateUtils { } + public static void selectXCreatorByWidgetName(String widgetName) { + FormDesigner designer = GuideCreateUtils.getFormDesigner(); + XCreator xCreator = GuideCreateUtils.getXCreatorFormDesigner(widgetName); + designer.getSelectionModel().reset(); + designer.getSelectionModel().selectACreator(xCreator); + } + public static XCreator findXCreator(XLayoutContainer container, String name) { if (StringUtils.equals(container.toData().getWidgetName(), name)) { return container; @@ -95,13 +133,18 @@ public class GuideCreateUtils { return new UILabel(ic); } - public static Rectangle getPopupMenuBounds(JPopupMenu popupMenu, Component parent, int x, int y) { + public static UILabel createTarget(JComponent component) { + ImageIcon ic = new ImageIcon(ScreenImage.createImage(component)); + return new UILabel(ic); + } + + public static Rectangle getRelativeBounds(JComponent component, Component parent, int x, int y) { Point point = SwingUtilities.convertPoint(parent,0,0, GuideManager.getInstance().getCurrentGuide().getGuideView().getRootPane()); - return new Rectangle(point.x + x, point.y + y, popupMenu.getWidth(), popupMenu.getHeight()); + return new Rectangle(point.x + x, point.y + y, component.getWidth(), component.getHeight()); } public static String openGuideFile(String sourcePath, String fileName, String suffix) { - String fileWorkPath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, UUID.randomUUID().toString() + suffix); + String fileWorkPath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, FILE_PREFIX + UUID.randomUUID().toString() + suffix); InputStream inputStream = GuideCreateUtils.class.getResourceAsStream(StableUtils.pathJoin(sourcePath, fileName + suffix)); byte[] data = ResourceIOUtils.inputStream2Bytes(inputStream); WorkContext.getWorkResource().write(fileWorkPath, data); @@ -113,9 +156,11 @@ public class GuideCreateUtils { WorkContext.getWorkResource().delete(filePath); } - public static void openDialogWithoutModal(JDialog dialog) { + public static void showDialogWithoutModal(JDialog dialog) { dialog.setModal(false); dialog.setVisible(true); - } + + + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideSceneHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideSceneHelper.java index 1571553cb..ac366b064 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideSceneHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideSceneHelper.java @@ -19,18 +19,6 @@ import com.fr.design.utils.ComponentUtils; import java.awt.Window; public class GuideSceneHelper { - public static GuideScene createWindowDisplayScene(Window window) { - DisplayScene scene = new DisplayScene(); - scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { - @Override - public boolean prepared() { - scene.addTarget(window); - return true; - } - }); - return scene; - } - public static GuideScene createFormDesignerBodyDisplayScene() { DisplayScene scene = new DisplayScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @@ -63,7 +51,7 @@ public class GuideSceneHelper { return scene; } - public static GuideScene createSelectXCretorClickScene(String widgetName) { + public static GuideScene createSelectXCreatorClickScene(String widgetName) { ClickScene scene = new ClickScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override 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 5703fd69f..eecf0a03c 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 @@ -20,24 +20,32 @@ import com.fr.design.mainframe.guide.scene.GuideScene; import com.fr.design.mainframe.guide.scene.GuideSceneLifecycleAdaptor; import com.fr.design.mainframe.guide.tip.GuideTip; import com.fr.design.utils.ComponentUtils; + +import javax.swing.SwingUtilities; +import java.awt.Point; import java.awt.Rectangle; public class ChangeLayoutComponentGuide { + private static final String TARGET_FROM_NAME = "chart0"; + private static final String TARGET_TO_NAME = "chart1"; private static UIButton switchButton; + private static String filePath; public static Guide createGuide() { GuideScene scene = createScene(); scene.nextScene(createScene2()) - .nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene()) .nextScene(createScene3()) + .nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene()) .nextScene(createScene4()) + .nextScene(createScene5()) .nextScene(GuideSceneHelper.createPreviewClickScene()); Guide guide = GuideBuilder.newInstance() .setID(GuideIds.Guide.F001002) .setName(Toolkit.i18nText("Fine-Design_Guide_Scene_F001002_Name")) .setDescription(Toolkit.i18nText("Fine-Design_Guide_Scene_F001002_Description")) + .setCompleteMessage(Toolkit.i18nText("Fine-Design_Guide_Scene_F001002_Complete_Message")) .addScene(scene) .registerLifecycle(new GuideLifecycleAdaptor() { @Override @@ -71,17 +79,14 @@ public class ChangeLayoutComponentGuide { } private static GuideScene createScene2() { - ClickScene scene = new ClickScene(); + DisplayScene scene = new DisplayScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override public boolean prepared() { scene.addCustomTarget( - GuideCreateUtils.createModalTarget(switchButton.getComponentPopupMenu()), - GuideCreateUtils.getPopupMenuBounds(switchButton.getComponentPopupMenu(), switchButton,0, -switchButton.getComponentPopupMenu().getHeight()) + GuideCreateUtils.createTarget(switchButton.getComponentPopupMenu()), + GuideCreateUtils.getRelativeBounds(switchButton.getComponentPopupMenu(), switchButton,0, -switchButton.getComponentPopupMenu().getHeight()) ); - scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001002_Tip_Select_Fix_layout"), null, GuideTip.Direction.RIGHT, 0.5f, 0.8f); - scene.addClickTarget(switchButton.getComponentPopupMenu().getComponent(1), ClickScene.ClickType.LEFT, true); - switchButton.getComponentPopupMenu().setVisible(false); return true; } }); @@ -89,13 +94,50 @@ public class ChangeLayoutComponentGuide { } private static GuideScene createScene3() { + ClickScene scene = new ClickScene(); + scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { + @Override + public boolean prepared() { + switchButton.getComponentPopupMenu().setVisible(true); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + scene.addCustomTarget( + GuideCreateUtils.createModalTarget(switchButton.getComponentPopupMenu()), + GuideCreateUtils.getRelativeBounds(switchButton.getComponentPopupMenu(), switchButton,0, -switchButton.getComponentPopupMenu().getHeight()) + ); + scene.addClickTarget(switchButton.getComponentPopupMenu().getComponent(1), ClickScene.ClickType.LEFT, true); + scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001002_Tip_Select_Fix_layout"), null, GuideTip.Direction.RIGHT, 0.5f, 0.8f); + switchButton.getComponentPopupMenu().setVisible(false); + scene.showScene(); + } + }); + return false; + } + }); + return scene; + } + + private static GuideScene createScene4() { DragScene scene = new DragScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override public boolean prepared() { - scene.addDragTarget(GuideCreateUtils.getFormDesigner(), GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(GuideCreateUtils.getXCreatorFormDesigner("absolute0")), DragScene.DragType.FROM); - scene.addDragTarget(GuideCreateUtils.getFormDesigner(), GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(GuideCreateUtils.getXCreatorFormDesigner("absolute1")), DragScene.DragType.TO); - scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001002_Tip_Drag"), GuideTip.Direction.TOP); + scene.addDragTarget(GuideCreateUtils.getFormDesigner(), GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(TARGET_FROM_NAME), DragScene.DragType.FROM); + scene.addDragTarget(GuideCreateUtils.getFormDesigner(), GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(TARGET_TO_NAME), DragScene.DragType.TO); + + Rectangle fromBounds = GuideCreateUtils.getXCreatorBoundsRelative2GuideView(TARGET_FROM_NAME); + Rectangle toBounds = GuideCreateUtils.getXCreatorBoundsRelative2GuideView(TARGET_TO_NAME); + + Point lineArrowPoint1 = new Point(fromBounds.x + fromBounds.width / 2, fromBounds.y - 5); + Point lineArrowPoint2 = new Point(fromBounds.x + fromBounds.width / 2, fromBounds.y - 25); + Point lineArrowPoint3 = new Point(toBounds.x + toBounds.width / 2, toBounds.y - 25); + Point lineArrowPoint4 = new Point(toBounds.x + toBounds.width / 2, toBounds.y - 5); + + scene.addLineArrow(lineArrowPoint1, lineArrowPoint2, lineArrowPoint3, lineArrowPoint4); + + Point bubbleAnchor = new Point((lineArrowPoint2.x + lineArrowPoint3.x) / 2, lineArrowPoint2.y); + scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001002_Tip_Drag"), null, GuideTip.Direction.TOP, bubbleAnchor, 0.5f); return super.prepared(); } @@ -103,8 +145,8 @@ public class ChangeLayoutComponentGuide { public void onComplete() { FormDesigner formDesigner = GuideCreateUtils.getFormDesigner(); - XCreator from = GuideCreateUtils.getXCreatorFormDesigner("absolute0"); - XLayoutContainer to = (XLayoutContainer) GuideCreateUtils.getXCreatorFormDesigner("absolute1"); + XCreator from = GuideCreateUtils.getXCreatorFormDesigner(TARGET_FROM_NAME); + XLayoutContainer to = (XLayoutContainer) GuideCreateUtils.getXCreatorFormDesigner(TARGET_TO_NAME); formDesigner.getSelectionModel().removeCreator(from, from.getWidth(), from.getHeight()); formDesigner.getSelectionModel().removeCreator(to, to.getWidth(),to.getHeight()); @@ -116,15 +158,13 @@ public class ChangeLayoutComponentGuide { return scene; } - private static GuideScene createScene4() { + private static GuideScene createScene5() { DisplayScene scene = new DisplayScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override public boolean prepared() { - Rectangle rootBounds = GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(GuideCreateUtils.getFormDesigner().getRootComponent()); - Rectangle bound3 = GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(GuideCreateUtils.getXCreatorFormDesigner("absolute2")); - Rectangle targetBounds = new Rectangle(rootBounds.x, rootBounds.y, rootBounds.width, bound3.y - rootBounds.y); - scene.addTarget(GuideCreateUtils.getFormDesigner(), targetBounds); + scene.addTarget(GuideCreateUtils.getFormDesigner(), GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(TARGET_FROM_NAME)); + scene.addTarget(GuideCreateUtils.getFormDesigner(), GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(TARGET_TO_NAME)); return true; } }); 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 d38db10b5..b7dd9c8c3 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 @@ -30,15 +30,22 @@ import com.fr.design.widget.ui.designer.PredefinedLayoutPane; import com.fr.form.share.Group; import com.fr.form.share.group.DefaultShareGroup; import com.fr.form.share.group.DefaultShareGroupManager; +import com.fr.stable.StringUtils; + import java.awt.Component; import java.util.ArrayList; import java.util.List; +import java.util.TimerTask; public class UseLayoutAndComponentGuide { + private static final String[] PRE_INSTALL_COMPONENTS = { + "大屏标题-酷炫蓝.25fcd194-d4db-406f-8a08-210f3c262870.reu", + "散点闪烁地图-酷炫蓝.5e17c2eb-5b18-4b6c-854a-5ffff7f6337a.reu", + "排名明细表.b4dab4f2-7b1a-4540-a2d4-65c3e080334e.reu" + }; + private static final String RESOURCE_PATH = "/com/fr/report/guide/component"; private static UIHeadMenu fileHeadMenu; private static NewFormPane newFormPane; - private static int autoInstallComponentCount; - private static String[] autoInstallComponentNames; public static Guide createGuide() { GuideScene scene = createScene(); @@ -46,9 +53,9 @@ public class UseLayoutAndComponentGuide { .nextScene(createScene3()) .nextScene(createScene4()) .nextScene(createScene5()) - .nextScene(createScene6("box0",0)) - .nextScene(createScene6("box1",1)) - .nextScene(createScene6("box2",2)) + .nextScene(createScene6("box0","25fcd194-d4db-406f-8a08-210f3c262870")) + .nextScene(createScene6("box1","5e17c2eb-5b18-4b6c-854a-5ffff7f6337a")) + .nextScene(createScene6("box2","b4dab4f2-7b1a-4540-a2d4-65c3e080334e")) .nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene()) .nextScene(GuideSceneHelper.createPreviewClickScene()); @@ -57,6 +64,7 @@ public class UseLayoutAndComponentGuide { .setID(GuideIds.Guide.F001001) .setName(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Name")) .setDescription(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Description")) + .setCompleteMessage(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Complete_Message")) .addScene(scene) .registerLifecycle(new GuideLifecycleAdaptor() { @Override @@ -101,8 +109,7 @@ public class UseLayoutAndComponentGuide { fileHeadMenu.getPopupMenu().setVisible(false); newFormPane = new NewFormPane(); - newFormPane.getWindow().setModal(false); - newFormPane.showWindow(); + GuideCreateUtils.showDialogWithoutModal(newFormPane.getWindow()); } }); return scene; @@ -113,8 +120,16 @@ public class UseLayoutAndComponentGuide { scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override public boolean prepared() { + GuideCreateUtils.TIMER.schedule(new TimerTask() { + @Override + public void run() { + scene.addTarget(newFormPane.getWindow()); + scene.showScene(); + GuideCreateUtils.TIMER.purge(); + } + }, 300); scene.addTarget(newFormPane.getWindow()); - return true; + return false; } }); return scene; @@ -175,20 +190,20 @@ public class UseLayoutAndComponentGuide { return scene; } - public static GuideScene createScene6(String name, int blockIndex) { + public static GuideScene createScene6(String name, String shareID) { DragScene scene = new DragScene(); scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override public boolean prepared() { scene.addDragTarget(GuideCreateUtils.getFormDesigner(), GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(getXOccupiedLayout(name)), DragScene.DragType.TO); - scene.addDragTarget(getLocalWidgetBlock(blockIndex), DragScene.DragType.FROM); + scene.addDragTarget(getLocalWidgetBlock(shareID), DragScene.DragType.FROM); scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Tip_Drag"), GuideTip.Direction.LEFT); return super.prepared(); } @Override public void onComplete() { - LocalWidgetBlock block = getLocalWidgetBlock(blockIndex); + LocalWidgetBlock block = getLocalWidgetBlock(shareID); XCreator xCreator = block.transformXCreator(block); XOccupiedLayout xOccupiedLayout = getXOccupiedLayout(name); GuideCreateUtils.addXCreatorToXLayoutContainer(xCreator, xOccupiedLayout, false); @@ -201,25 +216,22 @@ public class UseLayoutAndComponentGuide { return (XOccupiedLayout) GuideCreateUtils.getXCreatorFormDesigner(name); } - private static LocalWidgetBlock getLocalWidgetBlock(int index) { - return (LocalWidgetBlock) ComponentUtils.findComponentsByClass(LocalWidgetRepoPane.getInstance(), LocalWidgetBlock.class).get(index); + private static LocalWidgetBlock getLocalWidgetBlock(String id) { + List widgetBlockList = ComponentUtils.findComponentsByClass(LocalWidgetRepoPane.getInstance(), LocalWidgetBlock.class); + for (Component component : widgetBlockList) { + LocalWidgetBlock localWidgetBlock = (LocalWidgetBlock) component; + if (StringUtils.equals(localWidgetBlock.getBindInfo().getId(), id)) { + return localWidgetBlock; + } + } + return null; } private static void preloadShareComponent() { - autoInstallComponentCount = 3; try { + InstallComponentHelper.installShareComponents(RESOURCE_PATH, PRE_INSTALL_COMPONENTS); DefaultShareGroupManager.getInstance().refresh(); - Group shareGroup = DefaultShareGroupManager.getInstance().getGroup(DefaultShareGroup.GROUP_NAME); - if (shareGroup != null) { - DefaultShareGroup defaultShareGroup = (DefaultShareGroup) shareGroup; - int currentWidgetCount = defaultShareGroup.getAllBindInfoList().length; - autoInstallComponentCount = autoInstallComponentCount - (Math.min(autoInstallComponentCount, currentWidgetCount)); - } - if (autoInstallComponentCount > 0) { - autoInstallComponentNames = InstallComponentHelper.installPreComponent(autoInstallComponentCount); - DefaultShareGroupManager.getInstance().refresh(); - LocalWidgetRepoPane.getInstance().refreshAllGroupPane(); - } + LocalWidgetRepoPane.getInstance().refreshAllGroupPane(); } catch (Exception e) { e.printStackTrace(); } @@ -227,14 +239,12 @@ public class UseLayoutAndComponentGuide { static private void removeAutoInstalledComponent() { Group shareGroup = DefaultShareGroupManager.getInstance().getGroup(DefaultShareGroup.GROUP_NAME); - if (shareGroup != null && autoInstallComponentNames != null) { + if (shareGroup != null) { DefaultShareGroup defaultShareGroup = (DefaultShareGroup) shareGroup; List installedList = new ArrayList<>(); - for (String componentName : autoInstallComponentNames) { - if (componentName != null) { - String uuid = componentName.split("\\.")[1]; - installedList.add(uuid); - } + for (String componentName : PRE_INSTALL_COMPONENTS) { + String uuid = componentName.split("\\.")[1]; + installedList.add(uuid); } defaultShareGroup.unInstallSelect(installedList); LocalWidgetRepoPane.getInstance().refreshAllGroupPane(); 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 67bee2d99..ef6bf9053 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 @@ -3,7 +3,6 @@ package com.fr.design.mainframe.guide.creator.theme; import com.fr.base.theme.FormTheme; import com.fr.base.theme.FormThemeConfig; import com.fr.base.theme.TemplateTheme; -import com.fr.design.designer.creator.XCreator; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.style.FollowingThemePane; @@ -12,13 +11,10 @@ import com.fr.design.mainframe.CenterRegionContainerPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.EastRegionContainerPane; -import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.JForm; 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; @@ -30,11 +26,6 @@ import com.fr.design.mainframe.guide.tip.GuideTip; import com.fr.design.mainframe.theme.TemplateThemeBlock; import com.fr.design.mainframe.theme.dialog.TemplateThemeUsingDialog; import com.fr.design.utils.ComponentUtils; -import com.fr.file.FileNodeFILE; -import com.fr.file.filetree.FileNode; -import com.fr.stable.StableUtils; -import com.fr.stable.project.ProjectConstants; -import com.teamdev.jxbrowser.internal.ui.ToolkitKey; import javax.swing.SwingUtilities; import java.awt.Component; @@ -45,6 +36,7 @@ import java.util.TimerTask; public class ThemeToggleGuide { private static TemplateThemeUsingDialog themeDialog; + private static String TARGET_XCREATOR_NAME = "chart00"; private static String filePath; public static Guide createGuide() { @@ -54,7 +46,7 @@ public class ThemeToggleGuide { .nextScene(createScene3()) .nextScene(createScene4()) .nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene()) - .nextScene(GuideSceneHelper.createSelectXCretorClickScene("chart00")) + .nextScene(GuideSceneHelper.createSelectXCreatorClickScene(TARGET_XCREATOR_NAME)) .nextScene(createScene5()) .nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene()) .nextScene(GuideSceneHelper.createPreviewClickScene()); @@ -63,6 +55,7 @@ public class ThemeToggleGuide { .setID(GuideIds.Guide.F002001) .setName(Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Name")) .setDescription(Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Description")) + .setCompleteMessage(Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Complete_Message")) .addScene(scene1) .registerLifecycle(new GuideLifecycleAdaptor() { @Override @@ -73,6 +66,7 @@ public class ThemeToggleGuide { @Override public void onEnd() { + closeTemplateThemeUsingDialog(); GuideCreateUtils.deleteGuideFile(filePath); } }) @@ -107,19 +101,15 @@ public class ThemeToggleGuide { scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override public boolean prepared() { - new Timer().schedule(new TimerTask() { + GuideCreateUtils.TIMER.schedule(new TimerTask() { @Override public void run() { scene.addTarget(themeDialog); scene.showScene(); + GuideCreateUtils.TIMER.purge(); } - },100); - return true; - } - - @Override - public void onComplete() { - + },300); + return false; } }); @@ -139,10 +129,6 @@ public class ThemeToggleGuide { } return true; } - - @Override - public void onComplete() { - } }); return scene; } @@ -156,6 +142,11 @@ public class ThemeToggleGuide { scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Tip_Click_Confirm"), BubbleTip.Direction.TOP); return true; } + + @Override + public void onComplete() { + GuideCreateUtils.selectXCreatorByWidgetName(TARGET_XCREATOR_NAME); + } }); return scene; } @@ -166,7 +157,7 @@ public class ThemeToggleGuide { scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { @Override public boolean prepared() { - new Timer().schedule(new TimerTask() { + SwingUtilities.invokeLater(new Runnable() { @Override public void run() { Component target2 = ComponentUtils.findComponentByClass(EastRegionContainerPane.getInstance(), FollowingThemePane.class); @@ -182,10 +173,10 @@ public class ThemeToggleGuide { 0.5f, 0.8f ); - scene.showScene(); } + scene.showScene(); } - },1000); + }); return false; } @@ -204,7 +195,14 @@ public class ThemeToggleGuide { DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); themeDialog = new TemplateThemeUsingDialog<>(designerFrame, DesignerContext.getDesignerFrame().getSelectedJTemplate(), FormThemeConfig.getInstance()); } - themeDialog.setModal(false); - themeDialog.setVisible(true); + GuideCreateUtils.showDialogWithoutModal(themeDialog); + } + + private static void closeTemplateThemeUsingDialog() { + if (themeDialog != null) { + themeDialog.setVisible(false); + themeDialog.dispose(); + themeDialog = null; + } } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/guide/entry/GuideEntryPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/guide/entry/GuideEntryPane.java index 2058dc601..ce43fef6e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/guide/entry/GuideEntryPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/guide/entry/GuideEntryPane.java @@ -4,13 +4,11 @@ import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.guide.collect.GuideCollector; import com.fr.design.mainframe.guide.ui.BubbleHintDialog; import com.fr.design.mainframe.guide.ui.GuideManageDialog; import com.fr.general.IOUtils; -import javax.swing.SwingUtilities; import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; import java.awt.BorderLayout; @@ -47,7 +45,7 @@ public class GuideEntryPane extends BasicPane { button.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { - GuideManageDialog.getInstance().showDialog(); + onClick(); } }); this.setBackground(UIConstants.TEMPLATE_TAB_PANE_BACKGROUND); @@ -55,13 +53,10 @@ public class GuideEntryPane extends BasicPane { @Override public void ancestorAdded(AncestorEvent event) { if (!GuideCollector.getInstance().isShowHint()) { - BubbleHintDialog dialog = new BubbleHintDialog(DesignerContext.getDesignerFrame()); - Point point = new Point(0,0); - SwingUtilities.convertPointToScreen(point, GuideEntryPane.this); - Dimension size = GuideEntryPane.this.getSize(); - dialog.setLocationRelativeTo(GuideEntryPane.this); - dialog.setLocation(point.x - 187,point.y + size.height); - dialog.setVisible(true); + BubbleHintDialog dialog = BubbleHintDialog.getInstance(); + Point point = getLocationOnScreen(); + Dimension size = getSize(); + dialog.showDialog(new Point(point.x - 187,point.y + size.height)); } } @@ -76,4 +71,8 @@ public class GuideEntryPane extends BasicPane { } + private void onClick() { + GuideManageDialog.getInstance().showDialog(); + } + }