Browse Source

Pull request #6143: REPORT-60493 REPORT-60471 REPORT-60472 REPORT-60486 REPORT-60488 REPORT-60489 bug fixed

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

* commit '17ba276c01a477040ef5a553b56f15d32d9eff3f':
  REPORT-60489 主题切换弹窗提示文字修改&&解决长按导致底部dialog显示在最上层
  REPORT-60488 视觉优化
  REPORT-60486 布局切换引导拖拽问题&去除预览
  REPORT-60472 气泡提示文字不应该可以修改
  REPORT-60493 主题下载引导场景
  REPORT-60471 跟随主题点击后没有效果
  REPORT-60493 主题下载引导场景
research/11.0
Tommy 3 years ago
parent
commit
e24561bee7
  1. 1
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  2. 19
      designer-base/src/main/java/com/fr/design/mainframe/guide/base/Guide.java
  3. 1
      designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java
  4. 54
      designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java
  5. 7
      designer-base/src/main/java/com/fr/design/mainframe/guide/scene/ClickScene.java
  6. 9
      designer-base/src/main/java/com/fr/design/mainframe/guide/scene/DragScene.java
  7. 2
      designer-base/src/main/java/com/fr/design/mainframe/guide/tip/BubbleTip.java
  8. 2
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java
  9. 28
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java
  10. 7
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java
  11. 49
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java
  12. 73
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java
  13. 3
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/ChangeLayoutComponentGuide.java
  14. 3
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java
  15. 268
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java
  16. 8
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java

1
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -1005,6 +1005,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
button.addActionListener(actionListener);
}
button.setToolTipText(title);
button.setName(name);
}
public void processSnapChat() {

19
designer-base/src/main/java/com/fr/design/mainframe/guide/base/Guide.java

@ -108,6 +108,7 @@ public class Guide {
if (GuideManager.getInstance().getCurrentGuide() != null) {
return;
}
GuideManager.getInstance().setCurrentGuide(this);
try {
if (lifecycle != null && !lifecycle.prepared()) {
return;
@ -129,7 +130,6 @@ public class Guide {
if (scene != null) {
guideView.setScene(scene);
guideView.showGuide();
GuideManager.getInstance().setCurrentGuide(this);
if (lifecycle != null) {
lifecycle.onStart();
}
@ -159,11 +159,18 @@ public class Guide {
public void end() {
guideView.dismissGuide();
if (lifecycle != null) {
lifecycle.onEnd();
}
GuideManager.getInstance().setCurrentGuide(null);
GuideManageDialog.getInstance().showDialog();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (lifecycle != null) {
lifecycle.onEnd();
}
GuideManager.getInstance().setCurrentGuide(null);
GuideManageDialog.getInstance().showDialog();
}
});
}
public void registerLifecycle(GuideLifecycle lifecycle) {

1
designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java

@ -115,6 +115,7 @@ public class GuideView extends JDialog {
revalidate();
repaint();
setVisible(false);
dispose();
}
@Override

54
designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java

@ -283,39 +283,40 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene {
if (lifecycle != null && !lifecycle.prepared()) {
return;
}
showScene();
}
@Override
public void showScene() {
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--) {
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();
}
showContainer();
if (lifecycle != null) {
lifecycle.onShow();
}
showScene();
}
});
}
@Override
public void showScene() {
if (container != null) {
container.setContentPane(AbstractGuideScene.this);
setBounds(0, 0 , getSceneWidth(), getSceneWidth());
// 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();
}
showContainer();
if (lifecycle != null) {
lifecycle.onShow();
}
}
@Override
public void complete() {
container.getLayeredPane().remove(this);
@ -339,9 +340,6 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene {
} else {
GuideManager.getInstance().getCurrentGuide().complete();
}
}
@Override

7
designer-base/src/main/java/com/fr/design/mainframe/guide/scene/ClickScene.java

@ -2,6 +2,9 @@ package com.fr.design.mainframe.guide.scene;
import com.fr.design.mainframe.guide.base.GuideManager;
import javax.swing.AbstractButton;
import javax.swing.ButtonModel;
import javax.swing.SwingUtilities;
import java.awt.Component;
import java.awt.Point;
import java.awt.Rectangle;
@ -71,6 +74,10 @@ public class ClickScene extends AbstractGuideScene{
@Override
public void mousePressed(MouseEvent e) {
if (isDispatch) {
if (target instanceof AbstractButton) {
AbstractButton b = (AbstractButton) target;
b.setFocusable(false);
}
redispatchMouseEvent(e, target);
}
}

9
designer-base/src/main/java/com/fr/design/mainframe/guide/scene/DragScene.java

@ -45,19 +45,20 @@ public class DragScene extends AbstractGuideScene{
new DragAndDropDragGestureListener(target, DnDConstants.ACTION_COPY_OR_MOVE){
@Override
public void dragDropEnd(DragSourceDropEvent dsde) {
complete();
if (dsde.getDropSuccess()) {
complete();
}
}
};
} else if (dragType == DragType.TO) {
target.setDropTarget(new DropTarget());
target.setDropTarget(new DropSceneTarget());
}
}
private class DropSceneTarget extends DropTarget {
@Override
public synchronized void drop(DropTargetDropEvent dtde) {
super.drop(dtde);
complete();
dtde.dropComplete(true);
}
}
}

2
designer-base/src/main/java/com/fr/design/mainframe/guide/tip/BubbleTip.java

@ -36,7 +36,7 @@ public class BubbleTip implements GuideTip {
int returnVal = FineJOptionPane.showConfirmDialog(
currentGuide.getGuideView(),
"确认退出当前教学引导?",
Toolkit.i18nText("Fine-Design_Guide_Option_Warning_Terminal"),
Toolkit.i18nText("Fine-Design_Basic_Confirm"),
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);

2
designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java

@ -59,7 +59,7 @@ public class GuideCompleteDialog extends JDialog {
completeImage.setPreferredSize(new Dimension(DIALOG_WIDTH, ICON_HEIGHT));
JPanel container = new JPanel(new BorderLayout(0, 10));
container.setBorder(BorderFactory.createEmptyBorder(0, 52, 25, 52));
container.setBorder(BorderFactory.createEmptyBorder(15, 52, 25, 52));
UILabel title = new UILabel(Toolkit.i18nText("Fine-Design_Guide_Complete_Confirm"));
title.setFont(title.getFont().deriveFont(22.0f));

28
designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java

@ -2,12 +2,15 @@ package com.fr.design.mainframe.guide.ui.bubble;
import com.fr.base.GraphHelper;
import com.fr.design.gui.frpane.UITextPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
@ -35,10 +38,11 @@ public class BubbleWithClose extends Bubble {
private static final Color CONTENT_COLOR = new Color(51,51,52,128);
private static final Insets DEFAULT_INSET = new Insets(10, 15, 10, 15);
private String title;
private String content;
private UITextArea titleTextArea;
private UITextArea contentTextArea;
private UITextPane titleTextArea;
private UITextPane contentTextArea;
private UIButton closeButton;
public BubbleWithClose(String title, String content) {
@ -145,18 +149,24 @@ public class BubbleWithClose extends Bubble {
}
}
private UITextArea createTextArea(String str, Font font, Color foreground) {
UITextArea textArea= new UITextArea(str){
private UITextPane createTextArea(String str, Font font, Color foreground) {
UITextPane textArea= new UITextPane(){
@Override
public Insets getInsets() {
return new Insets(0, 0, 0, 0);
}
};
textArea.setEnabled(true);
textArea.setText(str);
textArea.setEnabled(false);
textArea.setDisabledTextColor(foreground);
textArea.setBorder(null);
textArea.setFont(font);
textArea.setOpaque(false);
textArea.setForeground(foreground);
StyledDocument doc = textArea.getStyledDocument();
SimpleAttributeSet center = new SimpleAttributeSet();
StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER);
doc.setParagraphAttributes(0, doc.getLength(), center, false);
return textArea;
}
@ -206,7 +216,7 @@ public class BubbleWithClose extends Bubble {
g2.fillRoundRect(bounds.x, bounds.y, bounds.width, HEADER_HEIGHT, 10, 10);
}
private int countLines(JTextArea textArea, int max_width) {
private int countLines(JTextPane textArea, int max_width) {
AttributedString text = new AttributedString(textArea.getText());
text.addAttribute(TextAttribute.FONT, textArea.getFont());
FontRenderContext frc = textArea.getFontMetrics(textArea.getFont())
@ -222,7 +232,7 @@ public class BubbleWithClose extends Bubble {
return lines;
}
private Dimension calTextSize(JTextArea textArea, int maxWidth) {
private Dimension calTextSize(JTextPane textArea, int maxWidth) {
if (textArea == null) {
return new Dimension(0, 0);
}

7
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java

@ -37,6 +37,8 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<Onlin
public AbstractOnlineWidgetBlock(OnlineShareWidget widget, OnlineWidgetSelectPane parentPane) {
super(widget);
this.parentPane = parentPane;
JPopupMenu popupMenu = createRightClickPopupMenu();
this.setComponentPopupMenu(popupMenu);
}
protected UILabel initCoverLabel(Image image) {
@ -104,10 +106,7 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<Onlin
super.mouseClicked(e);
if (e.getButton() == MouseEvent.BUTTON3) {
this.parentPane.hidePreviewPane();
JPopupMenu popupMenu = createRightClickPopupMenu();
GUICoreUtils.showPopupMenu(popupMenu, this, e.getX(), e.getY());
GUICoreUtils.showPopupMenu(getComponentPopupMenu(), this, e.getX(), e.getY());
}
}

49
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetRepoPane.java

@ -24,7 +24,6 @@ import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
@ -34,13 +33,29 @@ import java.util.concurrent.ExecutionException;
*/
public class OnlineWidgetRepoPane extends BasicPane {
private static final String MARKET_URL = "https://market.fanruan.com/reuse";
private static List<OnlineShareWidget>[] sharableWidgets;
private OnlineWidgetTabPane componentTabPane;
private JPanel centerPane;
private boolean isShowPackagePanel = false;
private CardLayout cardLayout;
private Status currentStatus;
enum Status {LOADING, DISCONNECTED, NORMAL}
public static boolean loadWidgets() {
if (sharableWidgets != null){
return true;
}
try{
sharableWidgets = ShareUtils.getAllSharableWidgetsFromShop();
return true;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
}
public static OnlineWidgetRepoPane getInstance() {
return OnlineWidgetRepoPane.HOLDER.singleton;
}
@ -77,7 +92,16 @@ public class OnlineWidgetRepoPane extends BasicPane {
this.add(createInternetErrorPane(), Status.DISCONNECTED.name());
switchPane(Status.LOADING);
synchronizedLoadingContent();
setContent();
}
private void setContent() {
if (sharableWidgets != null) {
initContentPane();
addCenterPane();
} else {
synchronizedLoadingContent();
}
}
private void addCenterPane() {
@ -91,6 +115,7 @@ public class OnlineWidgetRepoPane extends BasicPane {
}
private void switchPane(Status status) {
this.currentStatus = status;
cardLayout.show(this, status.name());
}
@ -100,7 +125,6 @@ public class OnlineWidgetRepoPane extends BasicPane {
protected Boolean doInBackground() throws Exception {
return initContentPane();
}
@Override
protected void done() {
try {
@ -118,24 +142,19 @@ public class OnlineWidgetRepoPane extends BasicPane {
}
private boolean initContentPane() {
List<OnlineShareWidget> sharableWidgets = new ArrayList<>();
List<OnlineShareWidget> sharableWidgetPackage = new ArrayList<>();
try {
ShareUtils.getAllSharableWidgetsFromShop(sharableWidgets, sharableWidgetPackage);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
boolean loadWidgetsSuccess = loadWidgets();
if (loadWidgetsSuccess) {
this.componentTabPane = new OnlineWidgetTabPane(sharableWidgets[0].toArray(new OnlineShareWidget[sharableWidgets[0].size()]),
sharableWidgets[1].toArray(new OnlineShareWidget[sharableWidgets[1].size()]));
} else {
switchPane(Status.DISCONNECTED);
return false;
}
this.componentTabPane = new OnlineWidgetTabPane(sharableWidgets.toArray(new OnlineShareWidget[sharableWidgets.size()]),
sharableWidgetPackage.toArray(new OnlineShareWidget[sharableWidgetPackage.size()]));
return true;
return loadWidgetsSuccess;
}
private void reload() {
this.removeAll();
sharableWidgets = null;
initPane();
this.validate();
this.repaint();

73
designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java

@ -3,13 +3,19 @@ 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.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.login.DesignerLoginHelper;
import com.fr.design.login.DesignerLoginSource;
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.design.utils.ComponentUtils;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.io.utils.ResourceIOUtils;
@ -21,11 +27,20 @@ import com.fr.workspace.WorkContext;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.InputStream;
import java.util.List;
import java.util.Timer;
import java.util.UUID;
@ -138,7 +153,7 @@ public class GuideCreateUtils {
return new UILabel(ic);
}
public static Rectangle getRelativeBounds(JComponent component, Component parent, int x, int y) {
public static Rectangle getRelativeBounds(Component 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, component.getWidth(), component.getHeight());
}
@ -159,8 +174,64 @@ public class GuideCreateUtils {
public static void showDialogWithoutModal(JDialog dialog) {
dialog.setModal(false);
dialog.setVisible(true);
dialog.toFront();
dialog.requestFocus();
}
public static void showUnLoginAlert() {
int returnVal = FineJOptionPane.showConfirmDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Guide_Option_Confirm_Not_Login"),
Toolkit.i18nText("Fine-Design_Basic_Confirm"),
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION) {
DesignerLoginHelper.showLoginDialog(DesignerLoginSource.NORMAL);
}
}
public static void showNoNetworkAlert() {
FineJOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Guide_Option_Warning_Need_Network"),
Toolkit.i18nText("Fine-Design_Basic_Confirm"),
JOptionPane.WARNING_MESSAGE);
}
public static JDialog showConfirmDialog(Window parent, Object message,
String title, int optionType) {
JOptionPane pane = new JOptionPane(message, JOptionPane.QUESTION_MESSAGE, optionType, null, FineJOptionPane.OPTION_OK_CANCEL, FineJOptionPane.OPTION_OK_CANCEL[0]);
int style = JRootPane.QUESTION_DIALOG;
JDialog dialog = new JDialog(parent, title);
dialog.setComponentOrientation(pane.getComponentOrientation());
Container contentPane = dialog.getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.add(pane, BorderLayout.CENTER);
dialog.setResizable(false);
if (JDialog.isDefaultLookAndFeelDecorated()) {
boolean supportsWindowDecorations =
UIManager.getLookAndFeel().getSupportsWindowDecorations();
if (supportsWindowDecorations) {
dialog.setUndecorated(true);
pane.getRootPane().setWindowDecorationStyle(style);
}
}
dialog.pack();
dialog.setLocationRelativeTo(parent);
List<Component> buttons = ComponentUtils.findComponentsByClass(pane, UIButton.class);
for (int i = 0; i < buttons.size(); i++) {
UIButton button = (UIButton) buttons.get(i);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
});
}
GuideCreateUtils.showDialogWithoutModal(dialog);
return dialog;
}
}

3
designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/ChangeLayoutComponentGuide.java

@ -38,8 +38,7 @@ public class ChangeLayoutComponentGuide {
.nextScene(createScene3())
.nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene())
.nextScene(createScene4())
.nextScene(createScene5())
.nextScene(GuideSceneHelper.createPreviewClickScene());
.nextScene(createScene5());
Guide guide = GuideBuilder.newInstance()
.setID(GuideIds.Guide.F001002)

3
designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java

@ -128,7 +128,6 @@ public class UseLayoutAndComponentGuide {
GuideCreateUtils.TIMER.purge();
}
}, 300);
scene.addTarget(newFormPane.getWindow());
return false;
}
});
@ -161,7 +160,7 @@ public class UseLayoutAndComponentGuide {
Component component = ComponentUtils.findComponentByName(newFormPane.getWindow().getContentPane(), UIDialog.OK_BUTTON);
if (component != null) {
scene.addClickTarget(component, ClickScene.ClickType.LEFT);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Tip_Click_Confirm"), GuideTip.Direction.TOP);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_Base_Tip_Click_Confirm"), GuideTip.Direction.TOP);
}
return super.prepared();
}

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

@ -1,22 +1,288 @@
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.base.theme.TemplateThemeConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UITabGroup;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.FormWidgetDetailPane;
import com.fr.design.mainframe.JTemplate;
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.GuideTip;
import com.fr.design.mainframe.share.ui.block.OnlineWidgetPackageBlock;
import com.fr.design.mainframe.share.ui.online.OnlineWidgetRepoPane;
import com.fr.design.mainframe.share.ui.online.OnlineWidgetTabPane;
import com.fr.design.mainframe.share.util.DownloadUtils;
import com.fr.design.utils.ComponentUtils;
import com.fr.form.share.utils.ShareUtils;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import java.awt.Component;
import java.awt.Point;
import java.awt.event.ContainerAdapter;
import java.awt.event.ContainerEvent;
import java.util.TimerTask;
import java.util.UUID;
public class DownloadComponentPackageGuide {
private static String filePath;
private static OnlineWidgetPackageBlock onlineWidgetPackageBlock;
private static String downloadThemeName;
private static JDialog themeConfirmDialog;
public static Guide createGuide() {
GuideScene scene = createScene();
scene.nextScene(createScene2())
.nextScene(createScene3())
.nextScene(createScene4())
.nextScene(createScene5())
.nextScene(createScene6())
.nextScene(GuideSceneHelper.createFormDesignerBodyDisplayScene());
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"))
.setCompleteMessage(Toolkit.i18nText("Fine-Design_Guide_Scene_F002002_Complete_Message"))
.addScene(scene)
.registerLifecycle(new GuideLifecycleAdaptor() {
@Override
public boolean prepared() {
String userName = DesignerEnvManager.getEnvManager().getDesignerLoginUsername();
if (!WorkContext.getCurrent().isRoot()) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Share_Download_Suitable_Theme_No_Authority_Tip_Message"),
Toolkit.i18nText("Fine-Design_Share_Download_Suitable_Theme_No_Authority_Tip_Title"),
JOptionPane.WARNING_MESSAGE);
return false;
} else if (StringUtils.isEmpty(userName)) {
GuideCreateUtils.showUnLoginAlert();
GuideManager.getInstance().getCurrentGuide().end();
return false;
} else if (!ShareUtils.testConnection()) {
GuideCreateUtils.showNoNetworkAlert();
GuideManager.getInstance().getCurrentGuide().end();
return false;
}
boolean loadWidgetSuccess = OnlineWidgetRepoPane.loadWidgets();
if (loadWidgetSuccess) {
filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "layout_recommend", ".frm");
EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS);
OnlineWidgetRepoPane onlineWidgetRepoPane = OnlineWidgetRepoPane.getInstance();
OnlineWidgetTabPane tabPane = (OnlineWidgetTabPane) ComponentUtils.findComponentByClass(onlineWidgetRepoPane, OnlineWidgetTabPane.class);
UITabGroup tabGroup = (UITabGroup) ComponentUtils.findComponentByClass(tabPane, UITabGroup.class);
JPanel centerPane = (JPanel) tabPane.getComponent(1);
if (centerPane.getComponentCount() > 0) {
GuideManager.getInstance().getCurrentGuide().start();
} else {
centerPane.addContainerListener(new ContainerAdapter() {
@Override
public void componentAdded(ContainerEvent e) {
GuideManager.getInstance().getCurrentGuide().start();
}
});
}
tabGroup.setSelectedIndex(1);
tabGroup.tabChanged(1);
} else {
GuideCreateUtils.showNoNetworkAlert();
GuideManager.getInstance().getCurrentGuide().end();
return false;
}
return false;
}
@Override
public void onEnd() {
closeConfirmDialog();
GuideCreateUtils.deleteGuideFile(filePath);
FormThemeConfig.getInstance().removeTheme(downloadThemeName);
filePath = null;
onlineWidgetPackageBlock = null;
downloadThemeName = null;
themeConfirmDialog = null;
}
})
.getGuide();
return guide;
}
private static void downLoadTheme() {
String themePath = onlineWidgetPackageBlock.getWidget().getThemePath();
FormTheme theme = DownloadUtils.downloadThemeFile(themePath);
if (theme == null) {
GuideCreateUtils.showNoNetworkAlert();
GuideManager.getInstance().getCurrentGuide().terminate();
}
downloadThemeName = theme.getName() + UUID.randomUUID().toString();
theme.setName(downloadThemeName);
FormThemeConfig.getInstance().addTheme(theme, true);
}
private static GuideScene createScene() {
ClickScene scene = new ClickScene();
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() {
@Override
public boolean prepared() {
Component button = ComponentUtils.findComponentByName(EastRegionContainerPane.getInstance().getLeftPane(), EastRegionContainerPane.KEY_WIDGET_LIB);
if (button instanceof UIButton) {
scene.addClickTarget(button, ClickScene.ClickType.LEFT, true);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F002002_Tip_Click_Widget_Lib"), GuideTip.Direction.BOTTOM);
}
return true;
}
@Override
public void onComplete() {
FormWidgetDetailPane.getInstance().swich2Online();
}
});
return scene;
}
private static GuideScene createScene2() {
ClickScene scene = new ClickScene();
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() {
@Override
public boolean prepared() {
onlineWidgetPackageBlock = (OnlineWidgetPackageBlock) ComponentUtils.findComponentByClass(EastRegionContainerPane.getInstance(), OnlineWidgetPackageBlock.class);
if (onlineWidgetPackageBlock != null) {
scene.addClickTarget(onlineWidgetPackageBlock, ClickScene.ClickType.RIGHT);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F002002_Tip_Right_Click_Package"), GuideTip.Direction.LEFT);
}
return true;
}
});
return scene;
}
private static GuideScene createScene3() {
DisplayScene scene = new DisplayScene();
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() {
@Override
public boolean prepared() {
scene.addTarget(onlineWidgetPackageBlock);
JPopupMenu popupMenu = onlineWidgetPackageBlock.getComponentPopupMenu();
Point location = getPopupMenuLocation();
scene.addCustomTarget(
GuideCreateUtils.createTarget(popupMenu),
GuideCreateUtils.getRelativeBounds(popupMenu, onlineWidgetPackageBlock, location.x, location.y)
);
return true;
}
});
return scene;
}
private static GuideScene createScene4() {
ClickScene scene = new ClickScene();
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() {
@Override
public boolean prepared() {
JPopupMenu popupMenu = onlineWidgetPackageBlock.getComponentPopupMenu();
Point location = getPopupMenuLocation();
scene.addCustomTarget(
GuideCreateUtils.createModalTarget(popupMenu),
GuideCreateUtils.getRelativeBounds(popupMenu, onlineWidgetPackageBlock, location.x, location.y)
);
scene.addCustomClickTarget(
GuideCreateUtils.createTarget((JComponent)popupMenu.getComponent(0)),
GuideCreateUtils.getRelativeBounds(popupMenu.getComponent(0), onlineWidgetPackageBlock, location.x, location.y),
ClickScene.ClickType.LEFT
);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F002002_Tip_Get_Current_Theme"), GuideTip.Direction.LEFT);
popupMenu.setVisible(false);
return true;
}
@Override
public void onComplete() {
downLoadTheme();
themeConfirmDialog = GuideCreateUtils.showConfirmDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Share_Apply_Suitable_Theme_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Confirm"),
FineJOptionPane.OK_CANCEL_OPTION);
}
});
return scene;
}
private static GuideScene createScene5() {
DisplayScene scene = new DisplayScene();
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() {
@Override
public boolean prepared() {
GuideCreateUtils.TIMER.schedule(new TimerTask() {
@Override
public void run() {
scene.addTarget(themeConfirmDialog);
scene.showScene();
GuideCreateUtils.TIMER.purge();
}
}, 300);
return false;
}
});
return scene;
}
private static GuideScene createScene6() {
ClickScene scene = new ClickScene();
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() {
@Override
public boolean prepared() {
Component target = ComponentUtils.findComponentByClass(themeConfirmDialog.getContentPane(), UIButton.class);
scene.addClickTarget(target, ClickScene.ClickType.LEFT);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_Base_Tip_Click_Confirm"), GuideTip.Direction.BOTTOM);
return super.prepared();
}
@Override
public void onComplete() {
closeConfirmDialog();
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
TemplateThemeConfig<? extends TemplateTheme> config = template.getUsingTemplateThemeConfig();
TemplateTheme theme = config.cachedFetch(downloadThemeName);
template.setTemplateTheme(theme);
}
});
return scene;
}
private static Point getPopupMenuLocation() {
JPopupMenu popupMenu = onlineWidgetPackageBlock.getComponentPopupMenu();
return new Point((onlineWidgetPackageBlock.getWidth() - popupMenu.getWidth()) / 2, (onlineWidgetPackageBlock.getHeight()- popupMenu.getHeight()) / 2);
}
private static void closeConfirmDialog() {
if (themeConfirmDialog != null) {
themeConfirmDialog.dispose();
}
}
}

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

@ -29,9 +29,6 @@ import com.fr.design.utils.ComponentUtils;
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 {
@ -61,6 +58,7 @@ public class ThemeToggleGuide {
@Override
public boolean prepared() {
filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "toggle_theme", ".frm");
EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS);
return true;
}
@ -139,7 +137,7 @@ public class ThemeToggleGuide {
@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);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_Base_Tip_Click_Complete"), BubbleTip.Direction.TOP);
return true;
}
@ -165,7 +163,7 @@ public class ThemeToggleGuide {
if (target2 != null) {
uiButtonGroup[0] = (UIButtonGroup) target2;
target2 = ((UIButtonGroup) target2).getButton(0);
scene.addClickTarget(target2, ClickScene.ClickType.LEFT);
scene.addClickTarget(target2, ClickScene.ClickType.LEFT, true);
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"),

Loading…
Cancel
Save