Browse Source

Pull request #6159: REPORT-60637 引导加载页

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

* commit 'cc31d98171cd7c7de7fdfe19a888dcf445acc9e0':
  REPORT-60637 国际化
  REPORT-60488 视觉优化
  REPORT-60637 引导加载页
research/11.0
Tommy 3 years ago
parent
commit
212abd6a1f
  1. 46
      designer-base/src/main/java/com/fr/design/mainframe/guide/base/Guide.java
  2. 21
      designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java
  3. 53
      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. 6
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java
  6. 2
      designer-base/src/main/java/com/fr/design/mainframe/guide/utils/ScreenImage.java
  7. BIN
      designer-base/src/main/resources/com/fr/design/mainframe/guide/close.png
  8. BIN
      designer-base/src/main/resources/com/fr/design/mainframe/guide/loading.gif
  9. 4
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java
  10. 10
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java
  11. 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() {

21
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;
@ -35,11 +37,12 @@ public class GuideView extends JDialog {
this.setUndecorated(true);
this.window = window;
this.modalColor = Color.BLACK;
this.modalOpacity = 0.4f;
this.modalOpacity = 0.6f;
this.setPreferredSize(window.getSize());
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);
}
});
}
}

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

@ -0,0 +1,53 @@
package com.fr.design.mainframe.guide.ui;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
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(Toolkit.i18nText("Fine-Design_Guide_Loading_Wait"));
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);
}
}
}

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

@ -7,6 +7,7 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import javax.swing.Icon;
import javax.swing.JTextPane;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
@ -32,6 +33,7 @@ import java.text.AttributedString;
public class BubbleWithClose extends Bubble {
private static final Font FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 14);
private static final Icon ICON = IOUtils.readIcon("/com/fr/design/mainframe/guide/close.png");
private static final int HEADER_HEIGHT = 24;
private static final Color HEADER_COLOR = new Color(245, 245, 246);
private static final Color TITLE_COLOR = new Color(51, 51, 52);
@ -112,9 +114,9 @@ public class BubbleWithClose extends Bubble {
private void createCloseButton() {
closeButton = new UIButton();
closeButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/guide/close.png"));
closeButton.setIcon(ICON);
closeButton.set4ToolbarButton();
closeButton.setPreferredSize(new Dimension(16, 16));
closeButton.setPreferredSize(new Dimension(12, 12));
closeButton.setRolloverEnabled(false);
closeButton.setPressedPainted(false);
this.add(closeButton);

2
designer-base/src/main/java/com/fr/design/mainframe/guide/utils/ScreenImage.java

@ -61,7 +61,7 @@ public class ScreenImage {
BufferedImage image = new BufferedImage(region.width, region.height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = image.createGraphics();
g2d.drawImage(createImage(component), 0, 0, null);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f));
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f));
g2d.setColor(Color.BLACK);
g2d.fillRect(0, 0, region.width, region.height);
g2d.dispose();

BIN
designer-base/src/main/resources/com/fr/design/mainframe/guide/close.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 B

After

Width:  |  Height:  |  Size: 1.1 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

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

@ -168,7 +168,9 @@ public class GuideCreateUtils {
}
public static void deleteGuideFile(String filePath) {
WorkContext.getWorkResource().delete(filePath);
if (filePath != null) {
WorkContext.getWorkResource().delete(filePath);
}
}
public static void showDialogWithoutModal(JDialog dialog) {

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