Browse Source

REPORT-60637 引导加载页

research/11.0
kuangshuai 3 years ago
parent
commit
b8e4fdb55a
  1. 46
      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

46
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 javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
public class Guide {
public enum GuideState {
@ -109,24 +110,41 @@ public class Guide {
return;
}
GuideManager.getInstance().setCurrentGuide(this);
try {
if (lifecycle != null && !lifecycle.prepared()) {
return;
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
start();
guideView.showLoading();
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() {
try {
if (lifecycle != null && !lifecycle.prepared()) {
return false;
}
return true;
} catch (Exception e) {
e.printStackTrace();
guideView.hideLoading();
terminate();
return false;
}
});
} catch (Exception e) {
e.printStackTrace();
end();
}
}
@Override
protected void done() {
try {
if (get()) {
start();
}
} catch (Exception e) {
e.printStackTrace();
guideView.hideLoading();
terminate();
}
}
}.execute();
}
public void start() {
guideView.hideLoading();
if (scene != null) {
guideView.setScene(scene);
guideView.showGuide();
@ -136,7 +154,6 @@ public class Guide {
} else {
complete();
}
}
public void complete() {
@ -159,7 +176,6 @@ public class Guide {
public void end() {
guideView.dismissGuide();
SwingUtilities.invokeLater(new Runnable() {
@Override
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.guide.scene.AbstractGuideScene;
import com.fr.design.mainframe.guide.scene.GuideScene;
import com.fr.design.mainframe.guide.ui.GuideLoadingGlassPane;
import javax.swing.JDialog;
import javax.swing.SwingUtilities;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Window;
@ -40,6 +42,7 @@ public class GuideView extends JDialog {
this.setSize(window.getSize());
this.setLayout(FRGUIPaneFactory.createBorderLayout());
setBg();
this.setGlassPane(new GuideLoadingGlassPane());
}
private WindowFocusListener windowFocusListener = new WindowFocusListener() {
@ -122,4 +125,20 @@ public class GuideView extends JDialog {
public void paint(Graphics 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() {
@Override
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.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F001001_Tip_New_Form"), GuideTip.Direction.BOTTOM);
scene.showScene();
return true;
}
@Override
public void onComplete() {
public void onShow() {
fileHeadMenu.setSelected(false);
fileHeadMenu.getPopupMenu().setVisible(false);
}
@Override
public void onComplete() {
newFormPane = new NewFormPane();
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_Title"),
JOptionPane.WARNING_MESSAGE);
GuideManager.getInstance().getCurrentGuide().terminate();
return false;
} else if (StringUtils.isEmpty(userName)) {
GuideCreateUtils.showUnLoginAlert();
GuideManager.getInstance().getCurrentGuide().end();
GuideManager.getInstance().getCurrentGuide().terminate();
return false;
} else if (!ShareUtils.testConnection()) {
GuideCreateUtils.showNoNetworkAlert();
GuideManager.getInstance().getCurrentGuide().end();
GuideManager.getInstance().getCurrentGuide().terminate();
return false;
}
boolean loadWidgetSuccess = OnlineWidgetRepoPane.loadWidgets();
@ -109,7 +110,7 @@ public class DownloadComponentPackageGuide {
tabGroup.tabChanged(1);
} else {
GuideCreateUtils.showNoNetworkAlert();
GuideManager.getInstance().getCurrentGuide().end();
GuideManager.getInstance().getCurrentGuide().terminate();
return false;
}
return false;

Loading…
Cancel
Save