Browse Source

REPORT-60637 引导加载页

research/11.0
kuangshuai 3 years ago
parent
commit
b8e4fdb55a
  1. 32
      designer-base/src/main/java/com/fr/design/mainframe/guide/base/Guide.java
  2. 19
      designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java
  3. 52
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideLoadingGlassPane.java
  4. 28
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/ImagePanel.java
  5. BIN
      designer-base/src/main/resources/com/fr/design/mainframe/guide/loading.gif
  6. 10
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java
  7. 7
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java

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

@ -7,6 +7,7 @@ import com.fr.design.mainframe.guide.ui.GuideManageDialog;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
public class Guide { public class Guide {
public enum GuideState { public enum GuideState {
@ -109,24 +110,41 @@ public class Guide {
return; return;
} }
GuideManager.getInstance().setCurrentGuide(this); GuideManager.getInstance().setCurrentGuide(this);
guideView.showLoading();
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() {
try { try {
if (lifecycle != null && !lifecycle.prepared()) { if (lifecycle != null && !lifecycle.prepared()) {
return; return false;
} }
SwingUtilities.invokeLater(new Runnable() { return true;
} catch (Exception e) {
e.printStackTrace();
guideView.hideLoading();
terminate();
return false;
}
}
@Override @Override
public void run() { protected void done() {
try {
if (get()) {
start(); start();
} }
});
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
end(); guideView.hideLoading();
terminate();
} }
}
}.execute();
} }
public void start() { public void start() {
guideView.hideLoading();
if (scene != null) { if (scene != null) {
guideView.setScene(scene); guideView.setScene(scene);
guideView.showGuide(); guideView.showGuide();
@ -136,7 +154,6 @@ public class Guide {
} else { } else {
complete(); complete();
} }
} }
public void complete() { public void complete() {
@ -159,7 +176,6 @@ public class Guide {
public void end() { public void end() {
guideView.dismissGuide(); guideView.dismissGuide();
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {

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

@ -4,8 +4,10 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.guide.scene.AbstractGuideScene; import com.fr.design.mainframe.guide.scene.AbstractGuideScene;
import com.fr.design.mainframe.guide.scene.GuideScene; import com.fr.design.mainframe.guide.scene.GuideScene;
import com.fr.design.mainframe.guide.ui.GuideLoadingGlassPane;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.SwingUtilities;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Window; import java.awt.Window;
@ -40,6 +42,7 @@ public class GuideView extends JDialog {
this.setSize(window.getSize()); this.setSize(window.getSize());
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
setBg(); setBg();
this.setGlassPane(new GuideLoadingGlassPane());
} }
private WindowFocusListener windowFocusListener = new WindowFocusListener() { private WindowFocusListener windowFocusListener = new WindowFocusListener() {
@ -122,4 +125,20 @@ public class GuideView extends JDialog {
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g); super.paint(g);
} }
public void showLoading() {
this.setVisible(true);
this.getGlassPane().setVisible(true);
}
public void hideLoading() {
this.getGlassPane().setVisible(false);
repaint();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setVisible(false);
}
});
}
} }

52
designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideLoadingGlassPane.java

@ -0,0 +1,52 @@
package com.fr.design.mainframe.guide.ui;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
public class GuideLoadingGlassPane extends JPanel {
private static final String loadingImagePath = "/com/fr/design/mainframe/guide/loading.gif";
private static GuideLoadingGlassPane loadingPane;
public static GuideLoadingGlassPane getInstance() {
if (loadingPane == null) {
loadingPane = new GuideLoadingGlassPane();
}
return loadingPane;
}
public GuideLoadingGlassPane() {
this.setLayout(new GridBagLayout());
this.setOpaque(false);
initComponent();
}
public void initComponent() {
JPanel loadingView = FRGUIPaneFactory.createBorderLayout_S_Pane();
loadingView.setOpaque(false);
loadingView.setPreferredSize(new Dimension(130, 120));
JPanel imageContainer = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane();
imageContainer.setOpaque(false);
ImagePanel imagePanel = new ImagePanel(loadingImagePath);
imagePanel.setOpaque(false);
imagePanel.setPreferredSize(new Dimension(84, 84));
imageContainer.add(imagePanel);
UILabel hintLabel = new UILabel("任务加载中,请稍后...");
hintLabel.setHorizontalAlignment(SwingConstants.CENTER);
hintLabel.setForeground(Color.WHITE);
loadingView.add(imageContainer, BorderLayout.NORTH);
loadingView.add(hintLabel, BorderLayout.SOUTH);
this.add(loadingView, new GridBagConstraints());
}
}

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

@ -0,0 +1,28 @@
package com.fr.design.mainframe.guide.ui;
import javax.swing.JPanel;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
/**
* Created by kerry on 2020-10-23
*/
public class ImagePanel extends JPanel {
private Image image;
public ImagePanel(String imagePath) {
image = Toolkit.getDefaultToolkit().createImage(ImagePanel.class
.getResource(imagePath));
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null) {
g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
}
}
}

BIN
designer-base/src/main/resources/com/fr/design/mainframe/guide/loading.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

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

@ -97,17 +97,25 @@ public class UseLayoutAndComponentGuide {
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { scene.registerLifecycle(new GuideSceneLifecycleAdaptor() {
@Override @Override
public boolean prepared() { public boolean prepared() {
scene.addCustomTarget(
GuideCreateUtils.createModalTarget(fileHeadMenu.getPopupMenu()),
GuideCreateUtils.getRelativeBounds(fileHeadMenu.getPopupMenu(), fileHeadMenu, 0 , fileHeadMenu.getHeight())
);
scene.addClickTarget(fileHeadMenu.getMenuComponent(2), ClickScene.ClickType.LEFT); scene.addClickTarget(fileHeadMenu.getMenuComponent(2), ClickScene.ClickType.LEFT);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Tip_New_Form"), GuideTip.Direction.BOTTOM); scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Tip_New_Form"), GuideTip.Direction.BOTTOM);
scene.showScene(); scene.showScene();
return true; return true;
} }
@Override @Override
public void onComplete() { public void onShow() {
fileHeadMenu.setSelected(false); fileHeadMenu.setSelected(false);
fileHeadMenu.getPopupMenu().setVisible(false); fileHeadMenu.getPopupMenu().setVisible(false);
}
@Override
public void onComplete() {
newFormPane = new NewFormPane(); newFormPane = new NewFormPane();
GuideCreateUtils.showDialogWithoutModal(newFormPane.getWindow()); GuideCreateUtils.showDialogWithoutModal(newFormPane.getWindow());
} }

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

@ -77,14 +77,15 @@ public class DownloadComponentPackageGuide {
Toolkit.i18nText("Fine-Design_Share_Download_Suitable_Theme_No_Authority_Tip_Message"), Toolkit.i18nText("Fine-Design_Share_Download_Suitable_Theme_No_Authority_Tip_Message"),
Toolkit.i18nText("Fine-Design_Share_Download_Suitable_Theme_No_Authority_Tip_Title"), Toolkit.i18nText("Fine-Design_Share_Download_Suitable_Theme_No_Authority_Tip_Title"),
JOptionPane.WARNING_MESSAGE); JOptionPane.WARNING_MESSAGE);
GuideManager.getInstance().getCurrentGuide().terminate();
return false; return false;
} else if (StringUtils.isEmpty(userName)) { } else if (StringUtils.isEmpty(userName)) {
GuideCreateUtils.showUnLoginAlert(); GuideCreateUtils.showUnLoginAlert();
GuideManager.getInstance().getCurrentGuide().end(); GuideManager.getInstance().getCurrentGuide().terminate();
return false; return false;
} else if (!ShareUtils.testConnection()) { } else if (!ShareUtils.testConnection()) {
GuideCreateUtils.showNoNetworkAlert(); GuideCreateUtils.showNoNetworkAlert();
GuideManager.getInstance().getCurrentGuide().end(); GuideManager.getInstance().getCurrentGuide().terminate();
return false; return false;
} }
boolean loadWidgetSuccess = OnlineWidgetRepoPane.loadWidgets(); boolean loadWidgetSuccess = OnlineWidgetRepoPane.loadWidgets();
@ -109,7 +110,7 @@ public class DownloadComponentPackageGuide {
tabGroup.tabChanged(1); tabGroup.tabChanged(1);
} else { } else {
GuideCreateUtils.showNoNetworkAlert(); GuideCreateUtils.showNoNetworkAlert();
GuideManager.getInstance().getCurrentGuide().end(); GuideManager.getInstance().getCurrentGuide().terminate();
return false; return false;
} }
return false; return false;

Loading…
Cancel
Save