Browse Source

Pull request #6197: REPORT-57813 主题引导是提前下载一页

Merge in DESIGN/design from ~TOMMY/design:feature/x to feature/x

* commit '4b744ae469a3ea4627e24ce1d489ef329ed771a1':
  REPORT-60798 在线获取主题右击组件包后异常
  REPORT-57813 主题引导是提前下载一页
research/11.0
Tommy 3 years ago
parent
commit
2882644745
  1. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java
  2. 42
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java
  3. 35
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java

2
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java

@ -58,7 +58,7 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
return null;
}
protected JPopupMenu getRightClickPopupMenu() {
public JPopupMenu getRightClickPopupMenu() {
return rightClickPopupMenu;
}

42
designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java

@ -40,10 +40,13 @@ import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import java.awt.Component;
import java.awt.Point;
import java.awt.event.ContainerAdapter;
import java.awt.event.ContainerEvent;
import java.util.List;
import java.util.TimerTask;
import java.util.UUID;
@ -170,12 +173,29 @@ public class DownloadComponentPackageGuide {
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() {
@Override
public boolean prepared() {
onlineWidgetPackageBlock = (OnlineWidgetPackageBlock) ComponentUtils.findComponentByClass(EastRegionContainerPane.getInstance(), OnlineWidgetPackageBlock.class);
if (onlineWidgetPackageBlock != null) {
List<Component> components = ComponentUtils.findComponentsByClass(EastRegionContainerPane.getInstance(), OnlineWidgetPackageBlock.class);
for (int index = 0; index < components.size(); index++) {
OnlineWidgetPackageBlock block = (OnlineWidgetPackageBlock) components.get(index);
if (StringUtils.isNotEmpty(block.getWidget().getThemePath())) {
onlineWidgetPackageBlock = block;
break;
}
}
if (onlineWidgetPackageBlock == null) {
GuideManager.getInstance().getCurrentGuide().terminate();
} else {
JScrollPane scrollPane = getParentScrollPane(onlineWidgetPackageBlock);
scrollPane.getVerticalScrollBar().setValue(onlineWidgetPackageBlock.getY());
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
scene.addClickTarget(onlineWidgetPackageBlock, ClickScene.ClickType.RIGHT);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F002002_Tip_Right_Click_Package"), GuideTip.Direction.LEFT);
scene.showScene();
}
return true;
});
}
return false;
}
});
return scene;
@ -187,7 +207,7 @@ public class DownloadComponentPackageGuide {
@Override
public boolean prepared() {
scene.addTarget(onlineWidgetPackageBlock);
JPopupMenu popupMenu = onlineWidgetPackageBlock.getComponentPopupMenu();
JPopupMenu popupMenu = onlineWidgetPackageBlock.getRightClickPopupMenu();
Point location = getPopupMenuLocation();
scene.addCustomTarget(
GuideCreateUtils.createTarget(popupMenu),
@ -204,7 +224,7 @@ public class DownloadComponentPackageGuide {
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() {
@Override
public boolean prepared() {
JPopupMenu popupMenu = onlineWidgetPackageBlock.getComponentPopupMenu();
JPopupMenu popupMenu = onlineWidgetPackageBlock.getRightClickPopupMenu();
Point location = getPopupMenuLocation();
scene.addCustomTarget(
GuideCreateUtils.createModalTarget(popupMenu),
@ -279,7 +299,7 @@ public class DownloadComponentPackageGuide {
}
private static Point getPopupMenuLocation() {
JPopupMenu popupMenu = onlineWidgetPackageBlock.getComponentPopupMenu();
JPopupMenu popupMenu = onlineWidgetPackageBlock.getRightClickPopupMenu();
return new Point((onlineWidgetPackageBlock.getWidth() - popupMenu.getWidth()) / 2, (onlineWidgetPackageBlock.getHeight()- popupMenu.getHeight()) / 2);
}
@ -289,4 +309,14 @@ public class DownloadComponentPackageGuide {
}
}
private static JScrollPane getParentScrollPane(Component component) {
if (component.getParent() == null) {
return null;
}
if (component.getParent() instanceof JScrollPane) {
return (JScrollPane) component.getParent();
}
return getParentScrollPane(component.getParent());
}
}

35
designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java

@ -1,5 +1,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.file.HistoryTemplateListCache;
@ -12,6 +13,7 @@ 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;
@ -20,6 +22,7 @@ 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.AsyncThemeFetcher;
import com.fr.design.mainframe.theme.TemplateThemeBlock;
import com.fr.design.mainframe.theme.TemplateThemeGridPagesPane;
import com.fr.design.mainframe.theme.dialog.TemplateThemeUsingDialog;
@ -27,12 +30,17 @@ import com.fr.design.utils.ComponentUtils;
import javax.swing.SwingUtilities;
import java.awt.Component;
import java.util.List;
import java.util.TimerTask;
public class ThemeToggleGuide {
private static final int PAGE_THEME_COUNT = 9;
private static final int DEFAULT_THEME_INDEX = 4;
private static TemplateThemeUsingDialog themeDialog;
private static String TARGET_XCREATOR_NAME = "chart00";
private static String filePath;
private static int themeLoadCount;
private static int selectedThemeIndex;
public static Guide createGuide() {
GuideScene scene1 = createScene1();
@ -55,15 +63,38 @@ public class ThemeToggleGuide {
.registerLifecycle(new GuideLifecycleAdaptor() {
@Override
public boolean prepared() {
List<String> themeNames = FormThemeConfig.getInstance().getThemeNames();
themeLoadCount = Math.min(themeNames.size(), PAGE_THEME_COUNT);
if (themeLoadCount == 0) {
GuideManager.getInstance().getCurrentGuide().terminate();
}
selectedThemeIndex = Math.min(themeLoadCount - 1, DEFAULT_THEME_INDEX);
int lazyCount = themeLoadCount;
AsyncThemeFetcher asyncThemeFetcher = new AsyncThemeFetcher<>(PAGE_THEME_COUNT, FormThemeConfig.getInstance());
for (int index = 0; index < lazyCount; index++) {
asyncThemeFetcher.submit(themeNames.get(index), new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter<FormTheme>(){
@Override
public void afterCachedFetch(FormTheme theme) {
themeLoadCount--;
if (themeLoadCount == 0) {
filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "toggle_theme", ".frm");
EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS);
return true;
asyncThemeFetcher.shutdown();
GuideManager.getInstance().getCurrentGuide().start();
}
}
});
}
return false;
}
@Override
public void onEnd() {
closeTemplateThemeUsingDialog();
GuideCreateUtils.deleteGuideFile(filePath);
filePath = null;
themeLoadCount = 0;
selectedThemeIndex = 0;
}
})
.getGuide();
@ -118,7 +149,7 @@ public class ThemeToggleGuide {
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() {
@Override
public boolean prepared() {
String name = FormThemeConfig.getInstance().getThemeNames().get(4);
String name = FormThemeConfig.getInstance().getThemeNames().get(selectedThemeIndex);
Component component = ComponentUtils.findComponentByName(themeDialog.getContentPane(), name);
if (component instanceof TemplateThemeBlock) {
scene.addClickTarget(component, ClickScene.ClickType.LEFT, true);

Loading…
Cancel
Save