kuangshuai
3 years ago
21 changed files with 1005 additions and 28 deletions
@ -0,0 +1,15 @@
|
||||
package com.fr.design.mainframe.guide; |
||||
|
||||
public class GuideIds { |
||||
public static class GuideGroup { |
||||
public static final String F01 = "F01"; |
||||
public static final String F02 = "F02"; |
||||
} |
||||
|
||||
public static class Guide { |
||||
public static final String F001001 = "F001001"; |
||||
public static final String F001002 = "F001002"; |
||||
public static final String F002001 = "F002001"; |
||||
public static final String F002002 = "F002002"; |
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fr.design.mainframe.guide; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.guide.base.GuideGroup; |
||||
import com.fr.design.mainframe.guide.base.GuideManager; |
||||
import com.fr.design.mainframe.guide.collect.GuideCollector; |
||||
import com.fr.design.mainframe.guide.creator.layout.ChangeLayoutComponentGuide; |
||||
import com.fr.design.mainframe.guide.creator.layout.UseLayoutAndComponentGuide; |
||||
import com.fr.design.mainframe.guide.creator.theme.DownloadComponentPackageGuide; |
||||
import com.fr.design.mainframe.guide.creator.theme.ThemeToggleGuide; |
||||
|
||||
public class GuideRegister { |
||||
public static void register() { |
||||
GuideCollector.getInstance().loadFromFile(); |
||||
registerGroup(); |
||||
registerGuide(); |
||||
} |
||||
|
||||
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"))); |
||||
} |
||||
|
||||
private static void registerGuide() { |
||||
GuideManager.getInstance().addGuide(GuideIds.GuideGroup.F01, UseLayoutAndComponentGuide.createGuide()); |
||||
GuideManager.getInstance().addGuide(GuideIds.GuideGroup.F01, ChangeLayoutComponentGuide.createGuide()); |
||||
GuideManager.getInstance().addGuide(GuideIds.GuideGroup.F02, ThemeToggleGuide.createGuide()); |
||||
GuideManager.getInstance().addGuide(GuideIds.GuideGroup.F02, DownloadComponentPackageGuide.createGuide()); |
||||
} |
||||
} |
@ -0,0 +1,118 @@
|
||||
package com.fr.design.mainframe.guide.creator; |
||||
|
||||
import com.fr.design.designer.beans.models.AddingModel; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.designer.creator.XLayoutContainer; |
||||
import com.fr.design.designer.creator.XOccupiedLayout; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.FormCreatorDropTarget; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.mainframe.JForm; |
||||
import com.fr.design.mainframe.guide.base.GuideManager; |
||||
import com.fr.design.mainframe.guide.utils.ScreenImage; |
||||
import com.fr.file.FileNodeFILE; |
||||
import com.fr.file.filetree.FileNode; |
||||
import com.fr.io.utils.ResourceIOUtils; |
||||
import com.fr.stable.StableUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.project.ProjectConstants; |
||||
import com.fr.workspace.WorkContext; |
||||
import sun.java2d.xr.XcbRequestCounter; |
||||
|
||||
import javax.swing.ImageIcon; |
||||
import javax.swing.JComponent; |
||||
import javax.swing.JPopupMenu; |
||||
import javax.swing.SwingUtilities; |
||||
import java.awt.Component; |
||||
import java.awt.Point; |
||||
import java.awt.Rectangle; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.image.BufferedImage; |
||||
import java.io.InputStream; |
||||
import java.util.UUID; |
||||
|
||||
public class GuideCreateUtils { |
||||
public static FormDesigner getFormDesigner() { |
||||
JForm jForm = (JForm) DesignerContext.getDesignerFrame().getSelectedJTemplate(); |
||||
FormDesigner designer = jForm.getFormDesign(); |
||||
return designer; |
||||
} |
||||
|
||||
public static Rectangle getXCreatorBoundsRelative2FormDesigner(XCreator xCreator) { |
||||
FormDesigner designer = getFormDesigner(); |
||||
Point point = SwingUtilities.convertPoint(xCreator, 0, 0, designer.getRootComponent()); |
||||
return new Rectangle(point.x + designer.getPaintX(), point.y + designer.getPaintY(), xCreator.getWidth(), xCreator.getHeight()); |
||||
} |
||||
|
||||
public static XCreator getXCreatorFormDesigner(String name) { |
||||
FormDesigner designer = getFormDesigner(); |
||||
XLayoutContainer rootComponent = designer.getRootComponent(); |
||||
return findXCreator(rootComponent, name); |
||||
|
||||
} |
||||
|
||||
public static XCreator findXCreator(XLayoutContainer container, String name) { |
||||
if (StringUtils.equals(container.toData().getWidgetName(), name)) { |
||||
return container; |
||||
} |
||||
for (Component component : container.getComponents()) { |
||||
if (component instanceof XLayoutContainer) { |
||||
XCreator xCreator = findXCreator((XLayoutContainer) component, name); |
||||
if (xCreator != null) { |
||||
return xCreator; |
||||
} |
||||
} else if (component instanceof XCreator) { |
||||
XCreator xCreator = (XCreator) component; |
||||
if (StringUtils.equals(xCreator.toData().getWidgetName(), name)) { |
||||
return xCreator; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public static void addXCreatorToXLayoutContainer(XCreator xCreator, XLayoutContainer xLayoutContainer, boolean isDragComponent) { |
||||
if (xCreator == null) { |
||||
return; |
||||
} |
||||
FormDesigner designer = GuideCreateUtils.getFormDesigner(); |
||||
designer.getSelectionModel().selectACreator(xLayoutContainer); |
||||
|
||||
if (isDragComponent) { |
||||
designer.setAddingModel(new AddingModel(xCreator, 0,0)); |
||||
designer.setDropTarget(new FormCreatorDropTarget(designer)); |
||||
designer.repaint(); |
||||
} else { |
||||
designer.startDraggingBean(xCreator); |
||||
} |
||||
|
||||
FormCreatorDropTarget dropTarget = (FormCreatorDropTarget) designer.getDropTarget(); |
||||
dropTarget.adding(xLayoutContainer.getX(), xLayoutContainer.getY()); |
||||
|
||||
designer.getSelectionModel().selectACreator(xCreator); |
||||
} |
||||
|
||||
public static UILabel createModalTarget(JComponent component) { |
||||
ImageIcon ic = new ImageIcon(ScreenImage.createImageWithModal(component)); |
||||
return new UILabel(ic); |
||||
} |
||||
|
||||
public static Rectangle getPopupMenuBounds(JPopupMenu popupMenu, 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()); |
||||
} |
||||
|
||||
public static String openGuideFile(String sourcePath, String fileName, String suffix) { |
||||
String fileWorkPath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, UUID.randomUUID().toString() + suffix); |
||||
InputStream inputStream = GuideCreateUtils.class.getResourceAsStream(StableUtils.pathJoin(sourcePath, fileName + suffix)); |
||||
byte[] data = ResourceIOUtils.inputStream2Bytes(inputStream); |
||||
WorkContext.getWorkResource().write(fileWorkPath, data); |
||||
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(fileWorkPath, false))); |
||||
return fileWorkPath; |
||||
} |
||||
|
||||
public static void deleteGuideFile(String filePath) { |
||||
WorkContext.getWorkResource().delete(filePath); |
||||
} |
||||
} |
@ -0,0 +1,63 @@
|
||||
package com.fr.design.mainframe.guide.creator; |
||||
|
||||
import com.fr.design.actions.file.WebPreviewUtils; |
||||
import com.fr.design.gui.ibutton.UIPreviewButton; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.CenterRegionContainerPane; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.mainframe.guide.base.GuideManager; |
||||
import com.fr.design.mainframe.guide.scene.ClickScene; |
||||
import com.fr.design.mainframe.guide.scene.DisplayScene; |
||||
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 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() { |
||||
@Override |
||||
public boolean prepared() { |
||||
FormDesigner formDesigner = GuideCreateUtils.getFormDesigner(); |
||||
scene.addTarget(formDesigner, GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(formDesigner.getRootComponent())); |
||||
return true; |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
public static GuideScene createPreviewClickScene() { |
||||
ClickScene scene = new ClickScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
scene.addClickTarget(ComponentUtils.findComponentByClass(CenterRegionContainerPane.getInstance(), UIPreviewButton.class), ClickScene.ClickType.LEFT); |
||||
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_Base_Click_Preview"), null, GuideTip.Direction.BOTTOM, 0.5f, 0.2f); |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void onComplete() { |
||||
GuideManager.getInstance().getCurrentGuide().getGuideView().dismissGuide(); |
||||
WebPreviewUtils.preview(DesignerContext.getDesignerFrame().getSelectedJTemplate()); |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
} |
@ -0,0 +1,133 @@
|
||||
package com.fr.design.mainframe.guide.creator.layout; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.designer.creator.XLayoutContainer; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.CenterRegionContainerPane; |
||||
import com.fr.design.mainframe.FormArea; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
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.creator.GuideCreateUtils; |
||||
import com.fr.design.mainframe.guide.creator.GuideSceneHelper; |
||||
import com.fr.design.mainframe.guide.scene.ClickScene; |
||||
import com.fr.design.mainframe.guide.scene.DisplayScene; |
||||
import com.fr.design.mainframe.guide.scene.DragScene; |
||||
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 java.awt.Rectangle; |
||||
|
||||
public class ChangeLayoutComponentGuide { |
||||
private static UIButton switchButton; |
||||
private static String filePath; |
||||
|
||||
public static Guide createGuide() { |
||||
GuideScene scene = createScene(); |
||||
scene.nextScene(createScene2()) |
||||
.nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene()) |
||||
.nextScene(createScene3()) |
||||
.nextScene(createScene4()) |
||||
.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")) |
||||
.addScene(scene) |
||||
.registerLifecycle(new GuideLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "layout_recommend", ".frm"); |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void onEnd() { |
||||
GuideCreateUtils.deleteGuideFile(filePath); |
||||
} |
||||
}) |
||||
.getGuide(); |
||||
|
||||
return guide; |
||||
} |
||||
|
||||
private static GuideScene createScene() { |
||||
ClickScene scene = new ClickScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
switchButton = (UIButton) ComponentUtils.findComponentByName(CenterRegionContainerPane.getInstance(), FormArea.FIX_LAYOUT_SWITCH_BUTTON); |
||||
scene.addClickTarget(switchButton, ClickScene.ClickType.LEFT, true); |
||||
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001002_Tip_Click_No_Fix_Layout"), GuideTip.Direction.TOP); |
||||
return true; |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
private static GuideScene createScene2() { |
||||
ClickScene scene = new ClickScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
scene.addCustomTarget( |
||||
GuideCreateUtils.createModalTarget(switchButton.getComponentPopupMenu()), |
||||
GuideCreateUtils.getPopupMenuBounds(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; |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
private static GuideScene createScene3() { |
||||
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); |
||||
return super.prepared(); |
||||
} |
||||
|
||||
@Override |
||||
public void onComplete() { |
||||
FormDesigner formDesigner = GuideCreateUtils.getFormDesigner(); |
||||
|
||||
XCreator from = GuideCreateUtils.getXCreatorFormDesigner("absolute0"); |
||||
XLayoutContainer to = (XLayoutContainer) GuideCreateUtils.getXCreatorFormDesigner("absolute1"); |
||||
|
||||
formDesigner.getSelectionModel().removeCreator(from, from.getWidth(), from.getHeight()); |
||||
formDesigner.getSelectionModel().removeCreator(to, to.getWidth(),to.getHeight()); |
||||
|
||||
GuideCreateUtils.addXCreatorToXLayoutContainer(from, (XLayoutContainer) GuideCreateUtils.getXCreatorFormDesigner("box1"), true); |
||||
GuideCreateUtils.addXCreatorToXLayoutContainer(to, (XLayoutContainer) GuideCreateUtils.getXCreatorFormDesigner("box0"), true); |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
private static GuideScene createScene4() { |
||||
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); |
||||
return true; |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
} |
@ -0,0 +1,242 @@
|
||||
package com.fr.design.mainframe.guide.creator.layout; |
||||
|
||||
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.EastRegionContainerPane; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.mainframe.FormWidgetDetailPane; |
||||
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.creator.GuideCreateUtils; |
||||
import com.fr.design.mainframe.guide.creator.GuideSceneHelper; |
||||
import com.fr.design.mainframe.guide.scene.ClickScene; |
||||
import com.fr.design.mainframe.guide.scene.DisplayScene; |
||||
import com.fr.design.mainframe.guide.scene.DragScene; |
||||
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.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.utils.ComponentUtils; |
||||
import com.fr.design.widget.ui.designer.NewFormPane; |
||||
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 java.awt.Component; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class UseLayoutAndComponentGuide { |
||||
private static UIHeadMenu fileHeadMenu; |
||||
private static NewFormPane newFormPane; |
||||
private static int autoInstallComponentCount; |
||||
private static String[] autoInstallComponentNames; |
||||
|
||||
public static Guide createGuide() { |
||||
GuideScene scene = createScene(); |
||||
scene.nextScene(createScene2()) |
||||
.nextScene(createScene3()) |
||||
.nextScene(createScene4()) |
||||
.nextScene(createScene5()) |
||||
.nextScene(createScene6("box0",0)) |
||||
.nextScene(createScene6("box1",1)) |
||||
.nextScene(createScene6("box2",2)) |
||||
.nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene()) |
||||
.nextScene(GuideSceneHelper.createPreviewClickScene()); |
||||
|
||||
|
||||
Guide guide = GuideBuilder.newInstance() |
||||
.setID(GuideIds.Guide.F001001) |
||||
.setName(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Name")) |
||||
.setDescription(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Description")) |
||||
.addScene(scene) |
||||
.registerLifecycle(new GuideLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
preloadShareComponent(); |
||||
Component component = ComponentUtils.findComponentByName(NorthRegionContainerPane.getInstance(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_File")); |
||||
fileHeadMenu = ((UIHeadMenu) component); |
||||
fileHeadMenu.setSelected(true); |
||||
fileHeadMenu.getPopupMenu().show(fileHeadMenu, 0, fileHeadMenu.getHeight()); |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void onEnd() { |
||||
fileHeadMenu.setSelected(false); |
||||
fileHeadMenu.getPopupMenu().setVisible(false); |
||||
if (newFormPane != null) { |
||||
newFormPane.getWindow().dispose(); |
||||
} |
||||
removeAutoInstalledComponent(); |
||||
} |
||||
}) |
||||
.getGuide(); |
||||
|
||||
return guide; |
||||
} |
||||
|
||||
public static GuideScene createScene() { |
||||
ClickScene scene = new ClickScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
scene.addClickTarget(fileHeadMenu.getMenuComponent(2), ClickScene.ClickType.LEFT); |
||||
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Tip_New_Form"), GuideTip.Direction.BOTTOM); |
||||
scene.showScene(); |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void onComplete() { |
||||
fileHeadMenu.setSelected(false); |
||||
fileHeadMenu.getPopupMenu().setVisible(false); |
||||
|
||||
newFormPane = new NewFormPane(); |
||||
newFormPane.getWindow().setModal(false); |
||||
newFormPane.showWindow(); |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
public static GuideScene createScene2() { |
||||
DisplayScene scene = new DisplayScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
scene.addTarget(newFormPane.getWindow()); |
||||
return true; |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
public static GuideScene createScene3() { |
||||
ClickScene scene = new ClickScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
List<Component> componentList = ComponentUtils.findComponentsByClass(newFormPane.getWindow().getContentPane(), PredefinedLayoutPane.class); |
||||
if (componentList.get(1) != null) { |
||||
PredefinedLayoutPane layoutPane = (PredefinedLayoutPane) componentList.get(1); |
||||
scene.addClickTarget(layoutPane, ClickScene.ClickType.LEFT, true); |
||||
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Tip_Select_Layout"), GuideTip.Direction.RIGHT); |
||||
} |
||||
|
||||
return super.prepared(); |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
public static GuideScene createScene4() { |
||||
ClickScene scene = new ClickScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
Component component = ComponentUtils.findComponentByName(newFormPane.getWindow().getContentPane(), UIDialog.OK_BUTTON); |
||||
if (component != null) { |
||||
scene.addClickTarget(component, ClickScene.ClickType.LEFT, true); |
||||
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Tip_Click_Confirm"), GuideTip.Direction.TOP); |
||||
} |
||||
return super.prepared(); |
||||
} |
||||
|
||||
@Override |
||||
public void onComplete() { |
||||
newFormPane.getWindow().dispose(); |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
public static GuideScene createScene5() { |
||||
DisplayScene scene = new DisplayScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
FormWidgetDetailPane.getInstance().switch2Local(); |
||||
EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_LIB); |
||||
FormDesigner formDesigner = GuideCreateUtils.getFormDesigner(); |
||||
scene.addTarget(formDesigner, GuideCreateUtils.getXCreatorBoundsRelative2FormDesigner(formDesigner.getRootComponent())); |
||||
return true; |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
public static GuideScene createScene6(String name, int blockIndex) { |
||||
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.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Tip_Drag"), GuideTip.Direction.LEFT); |
||||
return super.prepared(); |
||||
} |
||||
|
||||
@Override |
||||
public void onComplete() { |
||||
LocalWidgetBlock block = getLocalWidgetBlock(blockIndex); |
||||
XCreator xCreator = block.transformXCreator(block); |
||||
XOccupiedLayout xOccupiedLayout = getXOccupiedLayout(name); |
||||
GuideCreateUtils.addXCreatorToXLayoutContainer(xCreator, xOccupiedLayout, false); |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
private static XOccupiedLayout getXOccupiedLayout(String name) { |
||||
return (XOccupiedLayout) GuideCreateUtils.getXCreatorFormDesigner(name); |
||||
} |
||||
|
||||
private static LocalWidgetBlock getLocalWidgetBlock(int index) { |
||||
return (LocalWidgetBlock) ComponentUtils.findComponentsByClass(LocalWidgetRepoPane.getInstance(), LocalWidgetBlock.class).get(index); |
||||
} |
||||
|
||||
private static void preloadShareComponent() { |
||||
autoInstallComponentCount = 3; |
||||
try { |
||||
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(); |
||||
} |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
|
||||
static private void removeAutoInstalledComponent() { |
||||
Group shareGroup = DefaultShareGroupManager.getInstance().getGroup(DefaultShareGroup.GROUP_NAME); |
||||
if (shareGroup != null && autoInstallComponentNames != null) { |
||||
DefaultShareGroup defaultShareGroup = (DefaultShareGroup) shareGroup; |
||||
List<String> installedList = new ArrayList<>(); |
||||
for (String componentName : autoInstallComponentNames) { |
||||
if (componentName != null) { |
||||
String uuid = componentName.split("\\.")[1]; |
||||
installedList.add(uuid); |
||||
} |
||||
} |
||||
defaultShareGroup.unInstallSelect(installedList); |
||||
LocalWidgetRepoPane.getInstance().refreshAllGroupPane(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,22 @@
|
||||
package com.fr.design.mainframe.guide.creator.theme; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
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; |
||||
|
||||
public class DownloadComponentPackageGuide { |
||||
public static Guide createGuide() { |
||||
|
||||
Guide guide = GuideBuilder.newInstance() |
||||
.setID(GuideIds.Guide.F002002) |
||||
.setName(Toolkit.i18nText("Fine-Design_Guide_Scene_F002002_Name")) |
||||
.setDescription(Toolkit.i18nText("Fine-Design_Guide_Scene_F002002_Description")) |
||||
.registerLifecycle(new GuideLifecycleAdaptor() { |
||||
}) |
||||
.getGuide(); |
||||
|
||||
return guide; |
||||
} |
||||
} |
@ -0,0 +1,237 @@
|
||||
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; |
||||
import com.fr.design.i18n.Toolkit; |
||||
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; |
||||
import com.fr.design.mainframe.guide.scene.DisplayScene; |
||||
import com.fr.design.mainframe.guide.scene.GuideScene; |
||||
import com.fr.design.mainframe.guide.scene.GuideSceneLifecycleAdaptor; |
||||
import com.fr.design.mainframe.guide.tip.BubbleTip; |
||||
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; |
||||
import java.awt.Point; |
||||
import java.awt.Rectangle; |
||||
import java.util.Timer; |
||||
import java.util.TimerTask; |
||||
|
||||
public class ThemeToggleGuide { |
||||
private static TemplateThemeUsingDialog<FormTheme> themeDialog; |
||||
private static String filePath; |
||||
|
||||
public static Guide createGuide() { |
||||
GuideScene scene1 = createScene1(); |
||||
|
||||
scene1.nextScene(createScene2()) |
||||
.nextScene(createScene3()) |
||||
.nextScene(createScene4()) |
||||
.nextScene(createScene5()) |
||||
.nextScene(createScene6()) |
||||
.nextScene(GuideSceneHelper.createPreviewClickScene()); |
||||
|
||||
Guide guide = GuideBuilder.newInstance() |
||||
.setID(GuideIds.Guide.F002001) |
||||
.setName(Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Name")) |
||||
.setDescription(Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Description")) |
||||
.addScene(scene1) |
||||
.registerLifecycle(new GuideLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "toggle_theme", ".frm"); |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void onEnd() { |
||||
GuideCreateUtils.deleteGuideFile(filePath); |
||||
} |
||||
}) |
||||
.getGuide(); |
||||
|
||||
return guide; |
||||
} |
||||
|
||||
private static GuideScene createScene1() { |
||||
ClickScene scene = new ClickScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
TemplateTheme templateTheme = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateTheme(); |
||||
Component component = ComponentUtils.findComponentByName(CenterRegionContainerPane.getInstance(), templateTheme.getName()); |
||||
scene.addClickTarget(component, ClickScene.ClickType.LEFT); |
||||
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Tip_Click_Template_Theme"), GuideTip.Direction.BOTTOM); |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void onComplete() { |
||||
showTemplateThemeUsingDialog(); |
||||
} |
||||
}); |
||||
|
||||
return scene; |
||||
} |
||||
|
||||
private static GuideScene createScene2() { |
||||
DisplayScene scene = new DisplayScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
new Timer().schedule(new TimerTask() { |
||||
@Override |
||||
public void run() { |
||||
scene.addTarget(themeDialog); |
||||
scene.showScene(); |
||||
} |
||||
},100); |
||||
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() { |
||||
|
||||
} |
||||
}); |
||||
|
||||
return scene; |
||||
} |
||||
|
||||
private static GuideScene createScene3() { |
||||
ClickScene scene = new ClickScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
String name = FormThemeConfig.getInstance().getThemeNames().get(4); |
||||
Component component = ComponentUtils.findComponentByName(themeDialog.getContentPane(), name); |
||||
if (component instanceof TemplateThemeBlock) { |
||||
scene.addClickTarget(component, ClickScene.ClickType.LEFT, true); |
||||
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Tip_Toggle_Theme"), BubbleTip.Direction.TOP); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
@Override |
||||
public void onComplete() { |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
private static GuideScene createScene4() { |
||||
ClickScene scene = new ClickScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
scene.addClickTarget(ComponentUtils.findComponentByName(themeDialog, TemplateThemeUsingDialog.COMPLETE_BUTTON), ClickScene.ClickType.LEFT, true); |
||||
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F002001_Tip_Click_Confirm"), BubbleTip.Direction.TOP); |
||||
return true; |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
private static GuideScene createScene5() { |
||||
DisplayScene scene = new DisplayScene(); |
||||
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { |
||||
@Override |
||||
public boolean prepared() { |
||||
JForm jForm = (JForm) DesignerContext.getDesignerFrame().getSelectedJTemplate(); |
||||
scene.addTarget(jForm.getFormDesign()); |
||||
return true; |
||||
} |
||||
|
||||
@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); |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
private static GuideScene createScene6() { |
||||
ClickScene scene = new ClickScene(); |
||||
final UIButtonGroup[] uiButtonGroup = new UIButtonGroup[1]; |
||||
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; |
||||
} |
||||
|
||||
@Override |
||||
public void onComplete() { |
||||
if (uiButtonGroup[0] != null) { |
||||
uiButtonGroup[0].setSelectedIndex(0); |
||||
} |
||||
} |
||||
}); |
||||
return scene; |
||||
} |
||||
|
||||
private static void showTemplateThemeUsingDialog() { |
||||
if (themeDialog == null) { |
||||
DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); |
||||
themeDialog = new TemplateThemeUsingDialog<>(designerFrame, DesignerContext.getDesignerFrame().getSelectedJTemplate(), FormThemeConfig.getInstance()); |
||||
themeDialog.setModal(false); |
||||
} |
||||
if (!themeDialog.isVisible()) { |
||||
themeDialog.setVisible(true); |
||||
} |
||||
themeDialog.requestFocus(); |
||||
} |
||||
} |
Loading…
Reference in new issue