Browse Source

Merge pull request #145 in DESIGN/design from ~ZACK/design:release/10.0 to release/10.0

* commit '12b5356c1251bf34a439930e50777d71532aea8d':
  国际化
  rt
  REPORT-8813 设计器启动增加加载工程的loading
master
zack 6 years ago
parent
commit
96e5f220a9
  1. 17
      designer-base/src/com/fr/design/border/UIRoundedBorder.java
  2. 3
      designer-base/src/com/fr/design/gui/UIDefaultTheme.java
  3. 83
      designer-base/src/com/fr/design/gui/iprogressbar/ModernUIProgressBarUI.java
  4. 80
      designer-base/src/com/fr/design/gui/iprogressbar/ProgressDialog.java
  5. 4
      designer-base/src/com/fr/design/gui/iprogressbar/UIProgressBarUI.java
  6. 93
      designer-base/src/com/fr/design/gui/iprogressbar/UIProgressBorder.java
  7. 6
      designer-base/src/com/fr/design/mainframe/DesignerFrame.java
  8. 8
      designer-base/src/com/fr/design/mainframe/toolbar/UpdateActionManager.java
  9. 38
      designer-base/src/com/fr/start/BaseDesigner.java
  10. 31
      designer-realize/src/com/fr/start/Designer.java
  11. 19
      designer-realize/src/com/fr/start/module/DesignerStartup.java

17
designer-base/src/com/fr/design/border/UIRoundedBorder.java

@ -1,5 +1,8 @@
package com.fr.design.border;
import com.fr.base.GraphHelper;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
@ -7,10 +10,6 @@ import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.RoundRectangle2D;
import javax.swing.border.LineBorder;
import com.fr.base.GraphHelper;
public class UIRoundedBorder extends LineBorder {
private static final long serialVersionUID = 1L;
@ -36,7 +35,15 @@ public class UIRoundedBorder extends LineBorder {
this.lineStyle = lineStyle;
this.roundedCorner = roundedCorners;
}
public int getRoundedCorner() {
return roundedCorner;
}
public int getLineStyle() {
return lineStyle;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height){
Color oldColor = g.getColor();

3
designer-base/src/com/fr/design/gui/UIDefaultTheme.java

@ -1,6 +1,7 @@
package com.fr.design.gui;
import com.fr.design.constants.UIConstants;
import com.fr.design.utils.ThemeUtils;
import javax.swing.*;
@ -79,6 +80,8 @@ public class UIDefaultTheme extends DefaultMetalTheme {
table.put("TableHeader.background", new ColorUIResource(229, 229, 229));
table.put("ProgressBar.foreground", ThemeUtils.PROCESS_COLOR);
table.put("ProgressBar.background", ThemeUtils.TEXT_BG_COLOR);
table.put("ProgressBar.modern.foreground", new ColorUIResource(0x3497FF));
table.put("ProgressBar.modern.background", UIConstants.PROPERTY_PANE_BACKGROUND);
table.put("ProgressBar.selectionForeground", ThemeUtils.NORMAL_FOREGROUND);
table.put("ProgressBar.selectionBackground", ThemeUtils.NORMAL_FOREGROUND);
table.put("PopupMenu.background", ThemeUtils.NORMAL_BG);

83
designer-base/src/com/fr/design/gui/iprogressbar/ModernUIProgressBarUI.java

@ -0,0 +1,83 @@
package com.fr.design.gui.iprogressbar;
import com.fr.design.utils.ThemeUtils;
import javax.swing.LookAndFeel;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.RoundRectangle2D;
/**
* 新进度条UI(暂时只处理了非模糊场景)
* Created by zack on 2018/6/21.
*/
public class ModernUIProgressBarUI extends UIProgressBarUI {
// draw determinate
@Override
protected void drawXpHorzProgress(Graphics g, int x, int y,
int w, int h, int amountFull) {
Graphics2D g2d = (Graphics2D) g;
g2d.translate(x, y);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (!progressBar.isOpaque()) {
//绘制进度条背板
g2d.setColor(progressBar.getBackground());
RoundRectangle2D roundedRectangle = new RoundRectangle2D.Float(0, 0, w, h, 10, 10);
g2d.fill(roundedRectangle);
}
//
g2d.setColor(progressBar.getForeground());
int mx = 0;
while (mx < amountFull) {
RoundRectangle2D roundedRectangle = new RoundRectangle2D.Float(0, 0, amountFull, h, 10, 10);
g2d.fill(roundedRectangle);
mx += 8;
}
g2d.translate(-x, -y);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
// draw determinate
@Override
protected void drawXpVertProgress(Graphics g, int x, int y,
int w, int h, int amountFull) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.translate(x, y);
// paint the track
if (!progressBar.isOpaque()) {
g.setColor(progressBar.getBackground());
RoundRectangle2D roundedRectangle = new RoundRectangle2D.Float(0, 0, w, h, 10, 10);
g2d.fill(roundedRectangle);
}
// paints bottom to top...
int my = 0;
while (my < amountFull) {
RoundRectangle2D roundedRectangle = new RoundRectangle2D.Float(0, 0, w, amountFull, 10, 10);
g2d.fill(roundedRectangle);
my += 8;
}
g.translate(-x, -y);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
@Override
protected Color getSelectionForeground() {
return ThemeUtils.PROCESS_SELECTED_FORECOLOR;
}
@Override
protected Color getSelectionBackground() {
return ThemeUtils.PROCESS_SELECTED_BACKCOLOR;
}
@Override
protected void installDefaults() {
LookAndFeel.installBorder(progressBar, "ProgressBar.border");
LookAndFeel.installColorsAndFont(progressBar,
"ProgressBar.modern.background", "ProgressBar.modern.foreground", "ProgressBar.font");
}
}

80
designer-base/src/com/fr/design/gui/iprogressbar/ProgressDialog.java

@ -0,0 +1,80 @@
package com.fr.design.gui.iprogressbar;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.general.Inter;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.plaf.ColorUIResource;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
/**
* 加载进度弹窗
*/
public class ProgressDialog extends UIDialog {
private JProgressBar progressBar;
private JDialog centerDialog;
private JLabel text;
public ProgressDialog(Frame parent) {
super(parent);
setUndecorated(true);
setSize(parent.getSize());
setLocationRelativeTo(null);
setOpacity(0.5f);
initComponent();
}
private void initComponent() {
centerDialog = new JDialog(this);
centerDialog.setSize(new Dimension(482, 124));
centerDialog.setUndecorated(true);
GUICoreUtils.centerWindow(centerDialog);
JPanel panel = new JPanel();
panel.setBorder(new UIProgressBorder(3, UIConstants.DEFAULT_BG_RULER, 14, 46, 47, 37, 47));
panel.setLayout(new BorderLayout(4, 15));
progressBar = new JProgressBar();
progressBar.setUI(new ModernUIProgressBarUI());
progressBar.setBorderPainted(false);
progressBar.setOpaque(false);
progressBar.setBorder(null);
panel.add(progressBar, BorderLayout.CENTER);
text = new UILabel(Inter.getLocText("Fine-Designer_Loading_Project"), JLabel.CENTER);
FRFont font = FRFont.getInstance().applySize(14).applyForeground(new ColorUIResource(333334));
text.setFont(font);
panel.add(text, BorderLayout.SOUTH);
centerDialog.getContentPane().add(panel);
}
@Override
public void checkValid() throws Exception {
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
centerDialog.setVisible(b);
centerDialog.setResizable(false);
}
public void setProgressValue(int value) {
progressBar.setValue(value);
}
@Override
public void dispose() {
centerDialog.dispose();
super.dispose();
}
}

4
designer-base/src/com/fr/design/gui/iprogressbar/UIProgressBarUI.java

@ -74,7 +74,7 @@ public class UIProgressBarUI extends BasicProgressBarUI {
}
// draw determinate
private void drawXpHorzProgress(Graphics g, int x, int y,
protected void drawXpHorzProgress(Graphics g, int x, int y,
int w, int h, int amountFull) {
g.translate(x, y);
if (!progressBar.isOpaque()) {
@ -124,7 +124,7 @@ public class UIProgressBarUI extends BasicProgressBarUI {
// draw determinate
private void drawXpVertProgress(Graphics g, int x, int y,
protected void drawXpVertProgress(Graphics g, int x, int y,
int w, int h, int amountFull) {
g.translate(x, y);
// paint the track

93
designer-base/src/com/fr/design/gui/iprogressbar/UIProgressBorder.java

@ -0,0 +1,93 @@
package com.fr.design.gui.iprogressbar;
import com.fr.design.border.UIRoundedBorder;
import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.RenderingHints;
import java.awt.geom.RoundRectangle2D;
/**
* 进度条带阴影的边框
*/
public class UIProgressBorder extends UIRoundedBorder {
private int left;
private int right;
private int top;
private int bottom;
private static final long serialVersionUID = 1L;
public UIProgressBorder(Color color) {
super(color);
}
public UIProgressBorder(Color color, int thickness) {
super(color, thickness);
}
public UIProgressBorder(Color color, int thickness, int roundedCorners) {
super(color, thickness, roundedCorners);
}
public UIProgressBorder(int lineStyle, Color color, int roundedCorners) {
super(lineStyle, color, roundedCorners);
}
public UIProgressBorder(int lineStyle, Color color, int roundedCorners, int top, int left, int bottom, int right) {
super(lineStyle, color, roundedCorners);
this.top = top;
this.right = right;
this.bottom = bottom;
this.left = left;
}
@Override
public Insets getBorderInsets(Component c) {
Insets insets = new Insets(top, left, bottom, right);
return insets;
}
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Color oldColor = g.getColor();
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(getLineColor());
g2d.fill(new RoundRectangle2D.Double(x, y, width, height, 0, 0));
g2d.setColor(oldColor);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
paintBorderShadow(g2d, 7, x, y, width, height);
g2d.setColor(oldColor);
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1f));
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
private void paintBorderShadow(Graphics2D g2, int shadowWidth, int x, int y, int width, int height) {
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
shadowWidth = Math.max(shadowWidth, 2);
int sw = shadowWidth;
for (int i = sw; i > 0; i--) {
float pct = (float) (sw - i) / (sw - 1);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.01f * i));
g2.setColor(getMixedColor(Color.LIGHT_GRAY, 1.0f - pct, Color.WHITE, pct));
g2.setStroke(new BasicStroke(i));
g2.draw(new RoundRectangle2D.Double(x, y, width, height, getRoundedCorner(), getRoundedCorner()));
}
}
private static Color getMixedColor(Color c1, float pct1, Color c2, float pct2) {
float[] clr1 = c1.getComponents(null);
float[] clr2 = c2.getComponents(null);
for (int i = 0; i < clr1.length; i++) {
clr1[i] = (clr1[i] * pct1) + (clr2[i] * pct2);
}
return new Color(clr1[0], clr1[1], clr1[2], clr1[3]);
}
}

6
designer-base/src/com/fr/design/mainframe/DesignerFrame.java

@ -23,6 +23,7 @@ import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.TitlePlaceProcessor;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuHighLight;
import com.fr.design.gui.iprogressbar.ProgressDialog;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.layout.FRGUIPaneFactory;
@ -192,6 +193,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
closeButton.repaint();
}
};
private ProgressDialog progressDialog;
public DesignerFrame(ToolBarMenuDock ad) {
@ -269,6 +271,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.setDropTarget(new DropTarget(this, DnDConstants.ACTION_MOVE, new FileDropTargetListener(), true));
closeMode = UIConstants.CLOSE_OF_AUTHORITY;
initMenuPane();
this.progressDialog = new ProgressDialog(this);
}
/**
@ -1049,4 +1052,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
}
public ProgressDialog getProgressDialog() {
return progressDialog;
}
}

8
designer-base/src/com/fr/design/mainframe/toolbar/UpdateActionManager.java

@ -9,7 +9,6 @@ import com.fr.stable.StableUtils;
import javax.swing.JPanel;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@ -20,9 +19,9 @@ import java.util.concurrent.TimeUnit;
public class UpdateActionManager {
private static UpdateActionManager updateActionManager = null;
private List<UpdateActionModel> updateActions;
private ExecutorService threadPoolExecutor = new ThreadPoolExecutor(
1, 1,
0L, TimeUnit.MILLISECONDS,
private ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
1, 2,
30000L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(),
new ThreadFactoryBuilder().setNameFormat("alphafine-thread-%s").build());//目前测下来一个线程慢慢做处理总共大概也只要两秒,暂时就这样
@ -57,6 +56,7 @@ public class UpdateActionManager {
}
public synchronized void dealWithSearchText(final String paneClass, final UpdateAction updateAction) {
threadPoolExecutor.allowCoreThreadTimeOut(true);
threadPoolExecutor.execute(new Runnable() {
@Override
public void run() {

38
designer-base/src/com/fr/start/BaseDesigner.java

@ -11,6 +11,8 @@ import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.DesignerStartOpenFileProcessor;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.WestRegionContainerPane;
import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.utils.DesignUtils;
@ -36,12 +38,12 @@ import java.util.concurrent.Executors;
public abstract class BaseDesigner extends ToolBarMenuDock {
private static final int LOAD_TREE_MAXNUM = 10;
public BaseDesigner(String[] args) {
init(args);
}
private void init(String[] args) {
//初始化
EventDispatcher.fire(ModuleEvent.MajorModuleStarting, InterProviderFactory.getProvider().getLocText("FR-Designer_Initializing"));
@ -70,21 +72,37 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
HistoryTemplateListPane.getInstance();
}
});
service.submit(new Runnable() {
@Override
public void run() {
WestRegionContainerPane.getInstance();
}
});
service.submit(new Runnable() {
@Override
public void run() {
EastRegionContainerPane.getInstance();
}
});
service.shutdown();
}
public void show(final String[] args) {
collectUserInformation();
DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(10);
showDesignerFrame(args, DesignerContext.getDesignerFrame(), false);
DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(60);
DesignerContext.getDesignerFrame().refreshEnv();
DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(90);
for (int i = 0; !TemplateTreePane.getInstance().getTemplateFileTree().isTemplateShowing() && i < LOAD_TREE_MAXNUM; i++) {
TemplateTreePane.getInstance().getTemplateFileTree().refresh();
}
DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(100);
}
private void createDesignerFrame() {
new DesignerFrame(this);
}
@ -128,9 +146,9 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
}
}
}
private boolean openFile(final DesignerFrame df, boolean isException, FILE file) {
//启动时打开指定文件的接口
DesignerStartOpenFileProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerStartOpenFileProcessor.XML_TAG);
if (processor != null) {
@ -153,8 +171,8 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
df.getSelectedJTemplate().requestGridFocus();
return isException;
}
/**
* @param window
*/

31
designer-realize/src/com/fr/start/Designer.java

@ -21,7 +21,9 @@ import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.itoolbar.UILargeToolbar;
import com.fr.design.mainframe.ActiveKeyGenerator;
import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.InformationCollector;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JWorkBook;
@ -38,6 +40,7 @@ import com.fr.design.module.DesignModuleFactory;
import com.fr.design.module.DesignerModule;
import com.fr.design.utils.concurrent.ThreadFactoryBuilder;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.general.SiteCenter;
@ -56,9 +59,14 @@ import com.fr.start.preload.ImagePreLoader;
import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.border.MatteBorder;
import java.awt.*;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
@ -129,6 +137,25 @@ public class Designer extends BaseDesigner {
TemplateInfoCollector.getInstance();
}
});
service.submit(new Runnable() {
@Override
public void run() {
CellElementPropertyPane.getInstance();
}
});
service.submit(new Runnable() {
@Override
public void run() {
DesignerFrameFileDealerPane.getInstance();//这边会涉及到TemplateTreePane
}
});
service.submit(new Runnable() {
@Override
public void run() {
WidgetInfoConfig.getInstance();
}
});
service.shutdown();
}

19
designer-realize/src/com/fr/start/module/DesignerStartup.java

@ -11,6 +11,9 @@ import com.fr.startup.activators.BasicActivator;
import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created by juhaoyu on 2018/1/8.
*/
@ -21,18 +24,26 @@ public class DesignerStartup extends Activator {
startSub(PreStartActivator.class);
//启动基础部分
startSub(BasicActivator.class);
String[] args = getModule().upFindSingleton(StartupArgs.class).get();
Designer designer = new Designer(args);
final String[] args = getModule().upFindSingleton(StartupArgs.class).get();
final Designer designer = new Designer(args);
//启动env
startSub(DesignerWorkspaceProvider.class);
startSub(EnvBasedModule.class);
getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv();
ExecutorService service = Executors.newSingleThreadExecutor();
service.submit(new Runnable() {
@Override
public void run() {
designer.show(args);
DesignerContext.getDesignerFrame().getProgressDialog().dispose();
}
});
service.shutdown();
registerEnvListener();
DesignerContext.getDesignerFrame().setVisible(true);
//启动画面结束
SplashContext.getInstance().hide();
//启动设计器界面
designer.show(args);
DesignerContext.getDesignerFrame().getProgressDialog().setVisible(true);
startSub(StartFinishActivator.class);
}

Loading…
Cancel
Save