Browse Source

Pull request #6255: REPORT-61034 REPORT-60942 REPORT-61048 bug fixed

Merge in DESIGN/design from ~TOMMY/design:release/11.0 to release/11.0

* commit '7c88137c5bf4ecc37bae5c85823021d204f09118':
  REPORT-60942 视觉优化--高亮区域加个5像素的边框
  REPORT-60942 视觉优化
  REPORT-61048 远程服务器文件没有权限处理
  REPORT-60942 气泡弹窗交互更新
  REPORT-61034 mac 全屏时引导窗口未覆盖
bugfix/11.0
Tommy 3 years ago
parent
commit
fa9744642a
  1. 2
      designer-base/src/main/java/com/fr/design/mainframe/guide/base/GuideView.java
  2. 20
      designer-base/src/main/java/com/fr/design/mainframe/guide/scene/AbstractGuideScene.java
  3. 8
      designer-base/src/main/java/com/fr/design/mainframe/guide/tip/BubbleTip.java
  4. 28
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/BubbleHint.java
  5. 4
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/ExpandPane.java
  6. 23
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideCompleteDialog.java
  7. 2
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/GuideManageDialog.java
  8. 138
      designer-base/src/main/java/com/fr/design/mainframe/guide/ui/bubble/BubbleWithClose.java
  9. 58
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java
  10. 7
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/ChangeLayoutComponentGuide.java
  11. 2
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/layout/UseLayoutAndComponentGuide.java
  12. 5
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java
  13. 11
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/ThemeToggleGuide.java

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

@ -124,6 +124,6 @@ public class GuideView extends JDialog {
private void updateGuideViewLocation() {
GUICoreUtils.centerWindow(window, this);
this.setSize(getSize());
this.setBounds(window.getBounds());
}
}

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

@ -9,6 +9,7 @@ import com.fr.design.mainframe.guide.tip.BubbleTip;
import com.fr.design.mainframe.guide.tip.GuideTip;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JPanel;
@ -21,6 +22,7 @@ import java.awt.Composite;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Window;
@ -33,6 +35,7 @@ import java.util.List;
public abstract class AbstractGuideScene extends JPanel implements GuideScene {
private static final int DEFAULT_ARROW_HEIGHT = 12;
private static final int DEFAULT_ARROW_WIDTH = 18;
public static final Insets DEFAULT_HIGHLIGHT_INSETS = new Insets(5, 5, 5, 5);
private GuideScene nextScene;
private SceneFilter sceneFilter;
@ -169,9 +172,22 @@ public abstract class AbstractGuideScene extends JPanel implements GuideScene {
private UILabel getTargetComponentWithImage(BufferedImage image, Rectangle rectangle) {
ImageIcon ic = new ImageIcon(image);
UILabel label = new UILabel(ic);
UILabel label = new UILabel(ic){
@Override
public Insets getInsets() {
return DEFAULT_HIGHLIGHT_INSETS;
}
};
label.setBorder(BorderFactory.createMatteBorder(DEFAULT_HIGHLIGHT_INSETS.top, DEFAULT_HIGHLIGHT_INSETS.left, DEFAULT_HIGHLIGHT_INSETS.bottom, DEFAULT_HIGHLIGHT_INSETS.right, Color.WHITE));
label.setOpaque(true);
label.setBounds(rectangle);
label.setBounds(new Rectangle(
rectangle.x - DEFAULT_HIGHLIGHT_INSETS.left,
rectangle.y - DEFAULT_HIGHLIGHT_INSETS.top,
rectangle.width + DEFAULT_HIGHLIGHT_INSETS.left + DEFAULT_HIGHLIGHT_INSETS.right,
rectangle.height + DEFAULT_HIGHLIGHT_INSETS.top + DEFAULT_HIGHLIGHT_INSETS.bottom
));
return label;
}

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

@ -2,8 +2,6 @@ package com.fr.design.mainframe.guide.tip;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.guide.base.Guide;
import com.fr.design.mainframe.guide.base.GuideManager;
import com.fr.design.mainframe.guide.ui.bubble.Bubble;
@ -16,9 +14,11 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class BubbleTip implements GuideTip {
private static final int GAP = 5;
private BubbleWithClose bubbleBox;
private Point anchor;
/**
*
* @param title 标题
@ -70,12 +70,12 @@ public class BubbleTip implements GuideTip {
int bubbleW = bubbleBox.getPreferredSize().width;
int bubbleH = bubbleBox.getPreferredSize().height;
if (bubbleBox.isTailHorizontal()) {
int x = bubbleBox.isTailLeft() ? anchor.x : anchor.x - bubbleW;
int x = bubbleBox.isTailLeft() ? anchor.x + GAP : anchor.x - bubbleW - GAP;
int y = anchor.y - (int) (bubbleH * bubbleBox.getTailStart());
bubbleBox.setBounds(x, y, bubbleW, bubbleH);
} else if (bubbleBox.isTailVertical()) {
int x = anchor.x - (int) (bubbleW * bubbleBox.getTailStart());
int y = bubbleBox.isTailTop() ? anchor.y : anchor.y - bubbleH;
int y = bubbleBox.isTailTop() ? anchor.y + GAP : anchor.y - bubbleH - GAP;
bubbleBox.setBounds(x, y, bubbleW, bubbleH);
}
}

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

@ -17,6 +17,7 @@ import java.awt.event.ActionListener;
public class BubbleHint extends Bubble {
private UIButton confirmButton;
private static final Color CONTENT_TEXT_COLOR = new Color(51, 51, 52);
public BubbleHint() {
super(TailDirection.TOP, 0.9f);
@ -38,21 +39,21 @@ public class BubbleHint extends Bubble {
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
UILabel content1 = new UILabel(Toolkit.i18nText("Fine-Design_Guide_Tips_Content1"));
content1.setPreferredSize(new Dimension(190,20));
content1.setHorizontalAlignment(SwingConstants.CENTER);
UILabel content1 = createContentLabel(Toolkit.i18nText("Fine-Design_Guide_Tips_Content1"));
UILabel content2 = new UILabel(Toolkit.i18nText("Fine-Design_Guide_Tips_Content2"));
content2.setPreferredSize(new Dimension(190,20));
content2.setHorizontalAlignment(SwingConstants.CENTER);
UILabel content2 = createContentLabel(Toolkit.i18nText("Fine-Design_Guide_Tips_Content2"));
JPanel buttonContainer= FRGUIPaneFactory.createCenterFlowZeroGapBorderPane();
buttonContainer.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0));
buttonContainer.setBorder(BorderFactory.createEmptyBorder(15, 0, 0, 0));
buttonContainer.setPreferredSize(new Dimension(190,40));
buttonContainer.setOpaque(false);
confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Guide_Tips_Know"));
confirmButton.setPreferredSize(new Dimension(78, 24));
confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Guide_Tips_Know")) {
public Dimension getPreferredSize() {
return new Dimension(78, 24);
}
};
buttonContainer.add(confirmButton);
contentPane.add(title);
@ -71,4 +72,13 @@ public class BubbleHint extends Bubble {
confirmButton.removeActionListener(listener);
}
private UILabel createContentLabel(String text) {
UILabel content = new UILabel(text);
content.setPreferredSize(new Dimension(190,20));
content.setHorizontalAlignment(SwingConstants.CENTER);
content.setFont(content.getFont().deriveFont(14.0f));
content.setForeground(CONTENT_TEXT_COLOR);
return content;
}
}

4
designer-base/src/main/java/com/fr/design/mainframe/guide/ui/ExpandPane.java

@ -30,7 +30,7 @@ public class ExpandPane extends JPanel {
}
private void initComponent() {
VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP, 10, 5);
VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP, 10, 0);
layout.setAlignLeft(true);
this.setLayout(layout);
@ -47,7 +47,7 @@ public class ExpandPane extends JPanel {
private JPanel createHeader() {
headerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
headerPane.setPreferredSize(new Dimension(200, 24));
headerPane.setPreferredSize(new Dimension(200, 16));
UILabel headerTitle = new UILabel(this.title);
headerTitle.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
arrow = new UILabel(downIcon);

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

@ -14,7 +14,9 @@ import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.SwingConstants;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
@ -22,6 +24,7 @@ import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Window;
import java.awt.event.ActionEvent;
@ -34,12 +37,16 @@ public class GuideCompleteDialog extends JDialog {
private static final int ICON_HEIGHT = 182;
private static final Color FONT_COLOR = new Color(51, 51, 52);
private static final Color BUTTON_BG_COLOR = new Color(65, 155,249);
private static final Font TITLE_FONT = new Font(Font.SANS_SERIF, Font.BOLD, 22);
private static final Font CONTENT_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 18);
private static final Font BUTTON_FONT = new Font(Font.SANS_SERIF, Font.BOLD, 14);
private static GuideCompleteDialog dialog;
public static GuideCompleteDialog getInstance() {
if (dialog == null) {
dialog = new GuideCompleteDialog(DesignerContext.getDesignerFrame());
}
dialog = new GuideCompleteDialog(DesignerContext.getDesignerFrame());
return dialog;
}
@ -65,15 +72,16 @@ public class GuideCompleteDialog extends JDialog {
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));
title.setFont(TITLE_FONT);
title.setPreferredSize(new Dimension(190, 30));
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setForeground(FONT_COLOR);
textArea = new UITextPane();
changeLineSpacing(textArea, 0.19f,false);
textArea.setEnabled(false);
textArea.setOpaque(false);
textArea.setFont(textArea.getFont().deriveFont(18.0f));
textArea.setFont(CONTENT_FONT);
textArea.setPreferredSize(new Dimension(236, 52));
textArea.setBorder(null);
textArea.setDisabledTextColor(FONT_COLOR);
@ -83,7 +91,8 @@ public class GuideCompleteDialog extends JDialog {
doc.setParagraphAttributes(0, doc.getLength(), center, false);
JPanel buttonContainer= FRGUIPaneFactory.createCenterFlowZeroGapBorderPane();
buttonContainer.setPreferredSize(new Dimension(190,38));
buttonContainer.setPreferredSize(new Dimension(190,43));
buttonContainer.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
buttonContainer.setOpaque(false);
UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Guide_Complete_End")){
@ -92,6 +101,7 @@ public class GuideCompleteDialog extends JDialog {
return new Dimension(122, 38);
}
};
button.setFont(BUTTON_FONT);
button.setUI(confirmButtonUI);
button.setRoundBorder(true);
button.setForeground(Color.WHITE);
@ -131,4 +141,11 @@ public class GuideCompleteDialog extends JDialog {
}
}
};
private void changeLineSpacing(JTextPane pane, float factor, boolean replace) {
pane.selectAll();
MutableAttributeSet set = new SimpleAttributeSet(pane.getParagraphAttributes());
StyleConstants.setLineSpacing(set, factor);
pane.setParagraphAttributes(set, replace);
}
}

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

@ -74,7 +74,7 @@ public class GuideManageDialog extends JDialog {
}
private JPanel createGuideVersionPane(GuideVersion guideVersion) {
JPanel expandContent = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, VerticalFlowLayout.TOP, 0, 5);
JPanel expandContent = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, VerticalFlowLayout.TOP, 0, 10);
for (GuideGroup guideGroup : guideVersion.getGuideGroupList()) {
JPanel guideGroupCard = createGuideGroupCard(guideGroup);
expandContent.add(guideGroupCard);

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

@ -9,6 +9,7 @@ import com.fr.stable.StringUtils;
import javax.swing.Icon;
import javax.swing.JTextPane;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
@ -18,7 +19,6 @@ import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Rectangle;
@ -32,13 +32,21 @@ import java.text.AttributedCharacterIterator;
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 Font TITLE_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 14);
private static final Font CONTENT_FONT = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
private static final int TITLE_LINE_HEIGHT = 22;
private static final int CONTENT_LINE_HEIGHT = 18;
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);
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 static final Color HIGHLIGHT_COLOR = new Color(65, 155, 249);
private static final Insets DEFAULT_INSET = new Insets(15, 15, 15, 15);
private static final int MIN_WIDTH = 140;
private static final int MAX_WIDTH = 275;
private static final int ICON_GAP = 10;
private static final int ICON_SIZE = 10;
private static final int TEXT_GAP = 5;
private String title;
@ -46,6 +54,8 @@ public class BubbleWithClose extends Bubble {
private UITextPane titleTextArea;
private UITextPane contentTextArea;
private UIButton closeButton;
private Dimension titleSize;
private Dimension contentSize;
public BubbleWithClose(String title, String content) {
this(title, content, TailDirection.LEFT, 0.5f);
@ -87,23 +97,17 @@ public class BubbleWithClose extends Bubble {
@Override
public void componentResized(ComponentEvent e) {
Rectangle rectBounds = getRectBounds();
Dimension buttonSize = closeButton.getPreferredSize();
closeButton.setBounds(getWidth() - 10 - buttonSize.width, rectBounds.y + (HEADER_HEIGHT - buttonSize.height) / 2, buttonSize.width, buttonSize.height);
Dimension titleSize = new Dimension(0,0);
Dimension contentSize = new Dimension(0, 0);
closeButton.setBounds(rectBounds.x + rectBounds.width - DEFAULT_INSET.right - ICON_SIZE, rectBounds.y + 21, ICON_SIZE, ICON_SIZE);
if (titleTextArea != null) {
titleSize = calTextSize(titleTextArea, getTextAreaMaxWidth());
int x = rectBounds.x + (rectBounds.width - getHorizontalInsets() - titleSize.width) / 2 + DEFAULT_INSET.left;
int y = rectBounds.y + HEADER_HEIGHT + DEFAULT_INSET.top;
int x = rectBounds.x + DEFAULT_INSET.left;
int y = rectBounds.y + DEFAULT_INSET.top;
titleTextArea.setBounds(x, y, titleSize.width, titleSize.height);
}
if (contentTextArea != null) {
contentSize = calTextSize(contentTextArea, getTextAreaMaxWidth());
int x = rectBounds.x + (rectBounds.width - getHorizontalInsets() - contentSize.width) / 2 + DEFAULT_INSET.left;
int y = rectBounds.y = HEADER_HEIGHT + DEFAULT_INSET.top + (titleSize.height == 0 ? 0 : titleSize.height + 10);
int x = rectBounds.x + DEFAULT_INSET.left;
int y = rectBounds.y + DEFAULT_INSET.top + (titleSize.height == 0 ? 0 : titleSize.height + getTextGap());
contentTextArea.setBounds(x,y, contentSize.width, contentSize.height);
}
setSize(getPreferredSize().width, getPreferredSize().height);
@ -116,7 +120,7 @@ public class BubbleWithClose extends Bubble {
closeButton = new UIButton();
closeButton.setIcon(ICON);
closeButton.set4ToolbarButton();
closeButton.setPreferredSize(new Dimension(12, 12));
closeButton.setPreferredSize(new Dimension(ICON_SIZE, ICON_SIZE));
closeButton.setRolloverEnabled(false);
closeButton.setPressedPainted(false);
this.add(closeButton);
@ -138,44 +142,84 @@ public class BubbleWithClose extends Bubble {
private void createTitleTextArea() {
if (StringUtils.isNotEmpty(title)) {
titleTextArea = createTextArea(title, FONT, TITLE_COLOR);
titleTextArea = createTextArea(title, TITLE_FONT, TITLE_LINE_HEIGHT, TITLE_COLOR);
this.add(titleTextArea);
}
titleSize = calTextSize(titleTextArea, TITLE_LINE_HEIGHT, getTextAreaWidth(MAX_WIDTH), getTextAreaWidth(MIN_WIDTH));
}
private void createContentTextArea() {
if (StringUtils.isNotEmpty(content)) {
contentTextArea = createTextArea(content, FONT, CONTENT_COLOR);
contentTextArea = createTextArea(content, CONTENT_FONT, CONTENT_LINE_HEIGHT, CONTENT_COLOR);
this.add(contentTextArea);
}
contentSize = calTextSize(contentTextArea, CONTENT_LINE_HEIGHT, getTextAreaWidth(MAX_WIDTH), getTextAreaWidth(MIN_WIDTH));
}
private UITextPane createTextArea(String str, Font font, Color foreground) {
private UITextPane createTextArea(String str, Font font, int lineHeight, Color foreground) {
int lineSpace = lineHeight - font.getSize();
UITextPane textArea= new UITextPane(){
@Override
public Insets getInsets() {
return new Insets(0, 0, 0, 0);
return new Insets(lineSpace / 2 - 1, 0, lineSpace / 2, 0);
}
};
textArea.setText(str);
textArea.setEnabled(false);
textArea.setFont(font);
changeLineSpacing(textArea, lineHeight, true);
textArea.setEditable(false);
textArea.setForeground(foreground);
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);
textArea.setText(str);
highlightText(textArea);
return textArea;
}
private void changeLineSpacing(JTextPane pane, int lineHeight, boolean replace) {
pane.selectAll();
MutableAttributeSet set = new SimpleAttributeSet(pane.getParagraphAttributes());
FontMetrics fontMetrics = GraphHelper.getFontMetrics(pane.getFont());
StyleConstants.setLineSpacing(set, (float)(lineHeight - fontMetrics.getHeight()) / fontMetrics.getHeight());
pane.setParagraphAttributes(set, replace);
}
private void highlightText(JTextPane textArea) {
SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setForeground(sas, HIGHLIGHT_COLOR);
StyledDocument doc = textArea.getStyledDocument();
String text = textArea.getText();
int startPos = -1;
for (int i = 0; i < text.length(); i ++) {
char ch = text.charAt(i);
if (ch == '【') {
startPos = i;
}
if (ch == '】') {
if (startPos > 0) {
try {
doc.setCharacterAttributes(startPos, (i - startPos + 1), sas, false);
startPos = -1;
} catch (Exception e) {
}
}
}
}
}
@Override
protected int getDefaultWidth() {
return Math.max(titleSize.width, contentSize.width) + getHorizontalInsets() + ICON_GAP + ICON_SIZE + (isTailHorizontal() ? TAIL_HEIGHT : 0) ;
}
@Override
protected int getDefaultHeight() {
Dimension titleSize = calTextSize(titleTextArea, getDefaultTextAreaMaxWidth());
Dimension contentSize = calTextSize(contentTextArea, getDefaultTextAreaMaxWidth());
return (isTailVertical() ? TAIL_HEIGHT : 0) + HEADER_HEIGHT + titleSize.height + (titleSize.height == 0 ? 0 : 5) + contentSize.height + getVerticalInsets();
return titleSize.height + contentSize.height + getTextGap() + getVerticalInsets() + (isTailVertical() ? TAIL_HEIGHT : 0);
}
private int getTextGap() {
return (titleSize.height != 0 && contentSize.height != 0) ? TEXT_GAP : 0;
}
private LayoutManager getLayoutManager() {
@ -206,18 +250,6 @@ public class BubbleWithClose extends Bubble {
};
}
@Override
protected void paintBubbleBg(Graphics2D g2) {
super.paintBubbleBg(g2);
paintHeaderBg(g2);
}
private void paintHeaderBg(Graphics2D g2) {
g2.setColor(HEADER_COLOR);
Rectangle bounds = getRectBounds();
g2.fillRoundRect(bounds.x, bounds.y, bounds.width, HEADER_HEIGHT, 10, 10);
}
private int countLines(JTextPane textArea, int max_width) {
AttributedString text = new AttributedString(textArea.getText());
text.addAttribute(TextAttribute.FONT, textArea.getFont());
@ -234,28 +266,26 @@ public class BubbleWithClose extends Bubble {
return lines;
}
private Dimension calTextSize(JTextPane textArea, int maxWidth) {
private Dimension calTextSize(JTextPane textArea, int lineHeight, int maxWidth, int minWidth) {
if (textArea == null) {
return new Dimension(0, 0);
return new Dimension(minWidth, 0);
}
FontMetrics fontMetrics = GraphHelper.getFontMetrics(textArea.getFont());
int line = countLines(textArea, maxWidth);
int width = maxWidth;
if (line == 1) {
width = fontMetrics.stringWidth(textArea.getText());
width = Math.max(fontMetrics.stringWidth(textArea.getText()), minWidth);
}
int height = fontMetrics.getHeight() * line;
int height = lineHeight * line;
return new Dimension(width, height);
}
private int getTextAreaMaxWidth() {
return getWidth() - (isTailHorizontal() ? TAIL_HEIGHT : 0) -getHorizontalInsets();
}
private int getDefaultTextAreaMaxWidth() {
return BUBBLE_WIDTH - getHorizontalInsets();
private int getTextAreaWidth(int bubbleWidth) {
return bubbleWidth - getHorizontalInsets() - ICON_SIZE - ICON_GAP;
}
private int getHorizontalInsets() {
return DEFAULT_INSET.left + DEFAULT_INSET.right;
}

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

@ -14,6 +14,7 @@ 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.scene.AbstractGuideScene;
import com.fr.design.mainframe.guide.utils.ScreenImage;
import com.fr.design.utils.ComponentUtils;
import com.fr.file.FileNodeFILE;
@ -24,6 +25,7 @@ import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JDialog;
@ -32,8 +34,10 @@ import javax.swing.JRootPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Window;
@ -153,17 +157,60 @@ public class GuideCreateUtils {
return new UILabel(ic);
}
public static UILabel createTarget(JComponent component, boolean isModal, boolean withBorder) {
ImageIcon ic;
if (isModal) {
ic = new ImageIcon(ScreenImage.createImageWithModal(component));
} else {
ic = new ImageIcon(ScreenImage.createImage(component));
}
return createImageTarget(ic, withBorder);
}
private static UILabel createImageTarget(ImageIcon ic, boolean withBorder) {
if (withBorder) {
Insets insets = AbstractGuideScene.DEFAULT_HIGHLIGHT_INSETS;
UILabel label = new UILabel(ic){
@Override
public Insets getInsets() {
return insets;
}
};
label.setBorder(BorderFactory.createMatteBorder(insets.top, insets.left, insets.bottom, insets.right, Color.WHITE));
label.setOpaque(true);
return label;
} else {
return new UILabel(ic);
}
}
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());
}
public static Rectangle getRelativeBoundsWithBorder(Component component, Component parent, int x, int y) {
Rectangle rectangle = getRelativeBounds(component, parent, x, y);
Insets insets = AbstractGuideScene.DEFAULT_HIGHLIGHT_INSETS;
return new Rectangle(
rectangle.x - insets.left,
rectangle.y - insets.top,
rectangle.width + insets.left + insets.right,
rectangle.height + insets.top + insets.bottom
);
}
public static String openGuideFile(String sourcePath, String fileName, String suffix) {
String fileWorkPath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, FILE_PREFIX + UUID.randomUUID().toString() + suffix);
InputStream inputStream = GuideCreateUtils.class.getResourceAsStream(StableUtils.pathJoin(sourcePath, fileName + suffix));
byte[] data = ResourceIOUtils.inputStream2Bytes(inputStream);
WorkContext.getWorkResource().write(fileWorkPath, data);
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(fileWorkPath, false)));
FileNodeFILE fileNodeFILE= new FileNodeFILE(new FileNode(fileWorkPath, false));
if (!fileNodeFILE.exists()) {
return null;
}
DesignerContext.getDesignerFrame().openTemplate(fileNodeFILE);
return fileWorkPath;
}
@ -200,6 +247,15 @@ public class GuideCreateUtils {
JOptionPane.WARNING_MESSAGE);
}
public static void showNoFileAuthAlert() {
FineJOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.INFORMATION_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]);

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

@ -11,6 +11,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;
@ -21,7 +22,6 @@ import com.fr.design.mainframe.guide.scene.GuideSceneLifecycleAdaptor;
import com.fr.design.mainframe.guide.tip.GuideTip;
import com.fr.design.utils.ComponentUtils;
import javax.swing.SwingUtilities;
import java.awt.Point;
import java.awt.Rectangle;
@ -50,6 +50,11 @@ public class ChangeLayoutComponentGuide {
@Override
public boolean prepared() {
filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "layout_recommend", ".frm");
if (filePath == null) {
GuideCreateUtils.showNoFileAuthAlert();
GuideManager.getInstance().getCurrentGuide().terminate();
return false;
}
return true;
}

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

@ -105,7 +105,7 @@ public class UseLayoutAndComponentGuide {
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.RIGHT);
scene.showScene();
return true;
}

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

@ -94,6 +94,11 @@ public class DownloadComponentPackageGuide {
boolean loadWidgetSuccess = OnlineWidgetRepoPane.loadWidgets();
if (loadWidgetSuccess) {
filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "layout_recommend", ".frm");
if (filePath == null) {
GuideCreateUtils.showNoFileAuthAlert();
GuideManager.getInstance().getCurrentGuide().terminate();
return false;
}
EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS);
OnlineWidgetRepoPane onlineWidgetRepoPane = OnlineWidgetRepoPane.getInstance();
OnlineWidgetTabPane tabPane = (OnlineWidgetTabPane) ComponentUtils.findComponentByClass(onlineWidgetRepoPane, OnlineWidgetTabPane.class);

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

@ -78,9 +78,14 @@ public class ThemeToggleGuide {
themeLoadCount--;
if (themeLoadCount == 0) {
filePath = GuideCreateUtils.openGuideFile("/com/fr/report/guide/template", "toggle_theme", ".frm");
EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS);
asyncThemeFetcher.shutdown();
GuideManager.getInstance().getCurrentGuide().start();
if (filePath == null) {
GuideCreateUtils.showNoFileAuthAlert();
GuideManager.getInstance().getCurrentGuide().terminate();
} else {
EastRegionContainerPane.getInstance().switchTabTo(EastRegionContainerPane.KEY_WIDGET_SETTINGS);
asyncThemeFetcher.shutdown();
GuideManager.getInstance().getCurrentGuide().start();
}
}
}
});

Loading…
Cancel
Save