Browse Source

REPORT-99485 模版tab组件前导按钮绘制

newui
vito 11 months ago
parent
commit
8fdd4ef718
  1. 1
      designer-base/src/main/java/com/fine/theme/light/ui/FineLightIconSet.java
  2. 9
      designer-base/src/main/java/com/fine/theme/light/ui/FineTemplateTabPaneUI.java
  3. 1
      designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java
  4. 47
      designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java
  5. 173
      designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java
  6. 37
      designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java
  7. 36
      designer-base/src/main/java/com/fr/design/mainframe/ToolBarNewTemplatePane.java
  8. 6
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  9. 3
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java
  10. 3
      designer-base/src/main/java/com/fr/start/BaseDesigner.java
  11. 4
      designer-base/src/main/resources/com/fine/theme/icon/toolbar/more_hover.svg
  12. 3
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties

1
designer-base/src/main/java/com/fine/theme/light/ui/FineLightIconSet.java

@ -174,6 +174,7 @@ public class FineLightIconSet extends AbstractIconSet {
new SvgIconSource("tool_edit", "com/fine/theme/icon/toolbar/edit.svg", true),
new SvgIconSource("tool_edit_white", "com/fine/theme/icon/toolbar/edit_white.svg", true),
new SvgIconSource("tool_more", "com/fine/theme/icon/toolbar/more.svg", true),
new SvgIconSource("tool_more_hover", "com/fine/theme/icon/toolbar/more_hover.svg"),
// 参数面板
new SvgIconSource("param_edit", "com/fine/theme/icon/param/edit.svg", true, 24),

9
designer-base/src/main/java/com/fine/theme/light/ui/FineTemplateTabPaneUI.java

@ -26,6 +26,8 @@ import java.awt.geom.Rectangle2D;
import static com.fine.theme.utils.FineUIScale.scale;
import static com.fine.theme.utils.FineUIUtils.paintRoundTabBorder;
import static com.formdev.flatlaf.ui.FlatStylingSupport.Styleable;
import static com.fr.design.file.MultiTemplateTabPane.LEADING_WIDTH;
import static com.fr.design.file.MultiTemplateTabPane.TRAILING_WIDTH;
/**
* 文件Tab栏UI
@ -39,9 +41,6 @@ public class FineTemplateTabPaneUI extends PanelUI {
private static final String ELLIPSIS = "...";
private static final int ICON_TEXT_GAP = 4;
private static final int LEADING_WIDTH = 0;
private static final int TRAILING_WIDTH = 34;
@Styleable(dot = true)
protected Color background;
@ -111,7 +110,7 @@ public class FineTemplateTabPaneUI extends PanelUI {
closeHoverIcon = new LazyIcon("clear_hover");
addAction = new LazyIcon("add_worksheet");
moreAction = new LazyIcon("tool_more");
moreHoverAction = new LazyIcon("clear_hover");
moreHoverAction = new LazyIcon("tool_more_hover");
fileIcon = new LazyIcon("cpt_icon");
leadingWidth = scale(LEADING_WIDTH);
trailingWidth = scale(TRAILING_WIDTH);
@ -231,7 +230,7 @@ public class FineTemplateTabPaneUI extends PanelUI {
int x = leadingWidth + (int) tabPaneWidth + (trailingWidth - moreAction.getIconWidth()) / 2;
int y = (tabHeight - moreAction.getIconHeight()) / 2;
if (tabPane.isHoverMoreAction()) {
closeHoverIcon.paintIcon(tabPane, g2d, x, y);
moreHoverAction.paintIcon(tabPane, g2d, x, y);
} else {
moreAction.paintIcon(tabPane, g2d, x, y);
}

1
designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java

@ -25,6 +25,7 @@ public interface FineUIStyle {
String NORMAL_COLOR = "normalColor";
String TOP_TOOLS = "topTools";
String BRAND_COLOR_LABEL = "brandColorLabel";
String BUTTON_TAB_ACTION = "tabAction";
/**

47
designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java

@ -1,12 +1,16 @@
package com.fr.design.file;
import com.fine.swing.ui.layout.Layouts;
import com.fine.swing.ui.layout.Row;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.utils.FineUIStyle;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.file.LocateAction;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.imenu.UIScrollPopUpMenu;
@ -29,8 +33,8 @@ import com.fr.workspace.server.lock.TplOperator;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.MenuElement;
import javax.swing.SwingUtilities;
@ -40,6 +44,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
@ -47,7 +52,10 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.fine.theme.utils.FineClientProperties.BUTTON_TYPE_TOOLBAR_BUTTON;
import static com.fine.theme.utils.FineUIScale.scale;
import static com.fine.theme.utils.FineUIStyle.BUTTON_TAB_ACTION;
import static com.formdev.flatlaf.FlatClientProperties.BUTTON_TYPE;
import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog;
import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
import static javax.swing.JOptionPane.OK_OPTION;
@ -61,14 +69,21 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE;
* <p>
* created by daisy on 2013/08/05
**/
public class MultiTemplateTabPane extends JPanel {
public class MultiTemplateTabPane extends Row {
private static final String UI_CLASS_ID = "TemplateTabPaneUI";
private static final int GAP = 6;
private static final int SMALLGAP = 4;
private static final int TRAILING_WIDTH = 34;
private static final int LEADING_WIDTH = 0;
/**
* 尾部动作区宽度
*/
public static final int TRAILING_WIDTH = 34;
/**
* 前导动作区宽度
*/
public static final int LEADING_WIDTH = 38;
//每个标签页的最大的长度和最小长度。这些长度均为均分
@ -101,6 +116,7 @@ public class MultiTemplateTabPane extends JPanel {
private boolean hoverMoreAction = false;
private Icon clodeIcon = new LazyIcon("clear");
private boolean isShowList = false;
private JButton leadingActionButton;
//自动新建的模板B若没有进行任何编辑,切换到其他
//
@ -127,6 +143,7 @@ public class MultiTemplateTabPane extends JPanel {
* 多工作簿面板
*/
public MultiTemplateTabPane() {
this.addMouseListener(new MultiTemplateTabMouseListener());
this.addMouseMotionListener(new MultiTemplateTabMouseMotionListener());
this.setBorder(null);
@ -171,6 +188,28 @@ public class MultiTemplateTabPane extends JPanel {
}
}
});
add(
Layouts.cell(new UIButton(new LazyIcon("add_worksheet"))).with(it -> {
it.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_TOOLBAR_BUTTON);
FineUIStyle.setStyle(it, BUTTON_TAB_ACTION);
it.setFocusPainted(false);
leadingActionButton = it;
})
);
}
/**
* 为前导动作添加监听
*
* @param l 监听器
*/
public void addLeadingAction(ActionListener l) {
leadingActionButton.removeActionListener(l);
leadingActionButton.addActionListener(l);
}
public void setLeadingActionEnable(boolean enable){
leadingActionButton.setEnabled(enable);
}

173
designer-base/src/main/java/com/fr/design/file/NewTemplatePane.java

@ -1,173 +0,0 @@
package com.fr.design.file;
import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.constants.UIConstants;
import com.fr.design.mainframe.DesignerContext;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
// todo: 自己绘制组件
/**
* Author : daisy
* Date: 13-8-27
* Time: 下午6:07
*/
public abstract class NewTemplatePane extends JComponent implements MouseListener, MouseMotionListener {
private static final Icon GRAY_NEW_CPT = BaseUtils.readIcon("/com/fr/design/images/buttonicon/additicon_grey.png");
private static final int ICON_START_X = 5;
private static final int HEIGHT = 26;
private Graphics2D g2d;
private Icon newWorkBookIconMode = null;
public NewTemplatePane() {
newWorkBookIconMode = getNew();
this.setLayout(new BorderLayout(0, 0));
this.addMouseListener(this);
this.addMouseMotionListener(this);
this.setBorder(null);
}
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
dim.width = HEIGHT;
return dim;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g2d = (Graphics2D) g;
g2d.setColor(getBackground());
g2d.fill(new Rectangle2D.Double(0, 0, getWidth(),getHeight()));
int sheetIconY = (getHeight() - newWorkBookIconMode.getIconHeight()) / 2;
newWorkBookIconMode.paintIcon(this, g2d, ICON_START_X, sheetIconY);
// paintUnderLine(g2d);
}
private void paintUnderLine(Graphics2D g2d) {
//画下面的那条线
g2d.setPaint(UIConstants.LINE_COLOR);
g2d.draw(new Line2D.Double((float) 0, (float) (getHeight()-1), getWidth(), (float) (getHeight()-1)));
}
/**
*鼠标点击
* @param e 事件
*/
public void mouseClicked(MouseEvent e) {
if (needGrayNewCpt()) {
newWorkBookIconMode = GRAY_NEW_CPT;
}
}
/**
*鼠标按下
* @param e 事件
*/
public void mousePressed(MouseEvent e) {
int evtX = e.getX();
if (needGrayNewCpt()) {
newWorkBookIconMode = GRAY_NEW_CPT;
}
if (isOverNewIcon(evtX) && newWorkBookIconMode != GRAY_NEW_CPT) {
newWorkBookIconMode = getMousePressNew();
createNewTemplate();
}
this.repaint();
}
/**
* 新建模板
*/
protected void createNewTemplate() {
DesignerContext.getDesignerFrame().addAndActivateJTemplate();
}
/**
*鼠标松开
* @param e 事件
*/
public void mouseReleased(MouseEvent e) {
if (needGrayNewCpt()) {
newWorkBookIconMode = GRAY_NEW_CPT;
}
}
/**
*鼠标进入
* @param e 事件
*/
public void mouseEntered(MouseEvent e) {
if (needGrayNewCpt()) {
newWorkBookIconMode = GRAY_NEW_CPT;
}
}
/**
*鼠标离开
* @param e 事件
*/
public void mouseExited(MouseEvent e) {
if (needGrayNewCpt()) {
newWorkBookIconMode = GRAY_NEW_CPT;
} else {
newWorkBookIconMode = getNew();
}
this.repaint();
}
/**
*鼠标拖拽
* @param e 事件
*/
public void mouseDragged(MouseEvent e) {
}
/**
*鼠标移动
* @param e 事件
*/
public void mouseMoved(MouseEvent e) {
int evtX = e.getX();
if (needGrayNewCpt()) {
newWorkBookIconMode = GRAY_NEW_CPT;
} else if (isOverNewIcon(evtX)) {
newWorkBookIconMode = getMouseOverNew();
}
this.repaint();
}
private boolean needGrayNewCpt() {
return DesignerMode.isAuthorityEditing() || DesignerMode.isVcsMode();
}
private boolean isOverNewIcon(int evtX) {
return (evtX >= ICON_START_X && evtX <= ICON_START_X + newWorkBookIconMode.getIconWidth());
}
public void setButtonGray(boolean isGray) {
newWorkBookIconMode = isGray ? GRAY_NEW_CPT : getNew();
}
public abstract Icon getNew();
public abstract Icon getMouseOverNew();
public abstract Icon getMousePressNew();
}

37
designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java

@ -5,7 +5,6 @@ import com.fr.design.DesignState;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.MultiTemplateTabPane;
import com.fr.design.file.NewTemplatePane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UICombinationButton;
import com.fr.design.gui.itoolbar.UIToolbar;
@ -53,8 +52,7 @@ public class CenterRegionContainerPane extends JPanel {
private UIToolbar combineUp;//撤销重做 等工具栏
private JPanel templateTabPane;//新建模板 + 模板tab标签
private NewTemplatePane newWorkBookPane;//新建模板button
private MultiTemplateTabPane templateTabPane;//新建模板 + 模板tab标签
public static CenterRegionContainerPane getInstance() {
@ -77,8 +75,7 @@ public class CenterRegionContainerPane extends JPanel {
largeToolbar = getToolBarMenuDock().createLargeToolbar();
eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
combineUpTooBar();
templateTabPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
newWorkBookPane = getToolBarMenuDock().getNewTemplatePane();
templateTabPane = initTemplateTabPane();
eastCenterPane.add(templateTabPane, BorderLayout.NORTH);
eastCenterPane.add(combineUp, BorderLayout.CENTER);
@ -92,6 +89,13 @@ public class CenterRegionContainerPane extends JPanel {
setStyle(this, NORMAL_COLOR);
}
private MultiTemplateTabPane initTemplateTabPane() {
MultiTemplateTabPane templateTabPane = MultiTemplateTabPane.getInstance();
templateTabPane.addLeadingAction(e ->
DesignerContext.getDesignerFrame().addAndActivateJTemplate());
return templateTabPane;
}
public ToolBarMenuDock getToolBarMenuDock() {
return DesignerContext.getDesignerFrame().getToolBarMenuDock();
}
@ -230,18 +234,12 @@ public class CenterRegionContainerPane extends JPanel {
this.removeNorth();
this.add(customNorthPane, BorderLayout.NORTH);
}
if (strategy.hasTemplateTabPane(plus)) {
eastCenterPane.add(templateTabPane, BorderLayout.NORTH);
} else {
eastCenterPane.remove(templateTabPane);
}
if (strategy.hasCombineUp(plus)) {
eastCenterPane.add(combineUp, BorderLayout.CENTER);
} else {
eastCenterPane.remove(combineUp);
}
resetByDesignMode();
}
private void removeNorth() {
@ -264,18 +262,6 @@ public class CenterRegionContainerPane extends JPanel {
return false;
}
private void resetByDesignMode() {
if (DesignModeContext.isDuchampMode()) {
// eastPane.remove(largeToolbar);
//移除新建模板按钮
templateTabPane.remove(newWorkBookPane);
} else {
// eastPane.add(largeToolbar, BorderLayout.WEST);
templateTabPane.add(newWorkBookPane, BorderLayout.WEST);
}
}
JComponent getToolbarComponent() {
@ -286,8 +272,7 @@ public class CenterRegionContainerPane extends JPanel {
* 判断是否在权限编辑状态若是在权限编辑状态则需要有虚线框和关闭突变
*/
protected void needToAddAuhtorityPaint() {
newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing());
MultiTemplateTabPane.getInstance().setLeadingActionEnable(DesignModeContext.isAuthorityEditing());
}
@ -309,7 +294,7 @@ public class CenterRegionContainerPane extends JPanel {
* 重置下RegionContainerpane
*/
public void resetCenterRegionContainerPane() {
templateTabPane.add(MultiTemplateTabPane.getInstance(), BorderLayout.CENTER);
}
}

36
designer-base/src/main/java/com/fr/design/mainframe/ToolBarNewTemplatePane.java

@ -1,36 +0,0 @@
package com.fr.design.mainframe;
import com.fr.base.svg.IconUtils;
import com.fr.design.file.NewTemplatePane;
import javax.swing.Icon;
/**
* Created by hzzz on 2017/12/26.
*/
public class ToolBarNewTemplatePane extends NewTemplatePane {
private static final ToolBarNewTemplatePane instance = new ToolBarNewTemplatePane();
private ToolBarNewTemplatePane() {
}
public static NewTemplatePane getInstance() {
return instance;
}
@Override
public Icon getNew() {
return IconUtils.readIcon("/com/fr/design/standard/addicon/addicon");
}
@Override
public Icon getMouseOverNew() {
return IconUtils.readIcon("/com/fr/design/standard/addicon/add_press.svg");
}
@Override
public Icon getMousePressNew() {
return IconUtils.readIcon("/com/fr/design/standard/addicon/add_press.svg");
}
}

6
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -45,7 +45,6 @@ import com.fr.design.actions.server.PlatformManagerAction;
import com.fr.design.actions.server.PluginManagerAction;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.NewTemplatePane;
import com.fr.design.fun.MenuHandler;
import com.fr.design.fun.OemProcessor;
import com.fr.design.fun.PluginManagerProvider;
@ -59,7 +58,6 @@ import com.fr.design.gui.imenu.UIMenuBar;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.locale.impl.SupportLocaleImpl;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.ToolBarNewTemplatePane;
import com.fr.design.mainframe.platform.ServicePlatformAction;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
@ -782,10 +780,6 @@ public abstract class ToolBarMenuDock {
}
public NewTemplatePane getNewTemplatePane() {
return ToolBarNewTemplatePane.getInstance();
}
protected void insertMenu(MenuDef menuDef, String anchor) {
insertMenu(menuDef, anchor, new NoTargetAction());
}

3
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java

@ -13,7 +13,6 @@ import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.ToolBarNewTemplatePane;
import com.fr.design.mainframe.WestRegionContainerPane;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.menu.ToolBarDef;
@ -156,7 +155,7 @@ public class FileVersionsPanel extends BasicPane {
DesignModeContext.switchTo(isExit ? DesignerMode.NORMAL : DesignerMode.VCS);
// MutilTempalteTabPane & NewTemplatePane 是否可点
ToolBarNewTemplatePane.getInstance().setButtonGray(!isExit);
MultiTemplateTabPane.getInstance().setLeadingActionEnable(!isExit);
JTemplate<?, ?> currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (currentEditingTemplate.isJWorkBook()) {

3
designer-base/src/main/java/com/fr/start/BaseDesigner.java

@ -253,7 +253,8 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
private boolean createNewTemplate(DesignerFrame df) {
df.addAndActivateJTemplate();
// 如果没有模板,则需要确认一下
MultiTemplateTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
MultiTemplateTabPane.getInstance()
.setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
return true;
}

4
designer-base/src/main/resources/com/fine/theme/icon/toolbar/more_hover.svg

@ -0,0 +1,4 @@
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="2" y="2" width="28" height="28" rx="14" fill="#E6E9EF"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M28 16C28 22.6274 22.6274 28 16 28C9.37258 28 4 22.6274 4 16C4 9.37258 9.37258 4 16 4C22.6274 4 28 9.37258 28 16ZM30 16C30 23.732 23.732 30 16 30C8.26801 30 2 23.732 2 16C2 8.26801 8.26801 2 16 2C23.732 2 30 8.26801 30 16ZM10.5 17.5C11.3284 17.5 12 16.8284 12 16C12 15.1716 11.3284 14.5 10.5 14.5C9.67157 14.5 9 15.1716 9 16C9 16.8284 9.67157 17.5 10.5 17.5ZM16 17.5C16.8284 17.5 17.5 16.8284 17.5 16C17.5 15.1716 16.8284 14.5 16 14.5C15.1716 14.5 14.5 15.1716 14.5 16C14.5 16.8284 15.1716 17.5 16 17.5ZM23 16C23 16.8284 22.3284 17.5 21.5 17.5C20.6716 17.5 20 16.8284 20 16C20 15.1716 20.6716 14.5 21.5 14.5C22.3284 14.5 23 15.1716 23 16Z" fill="#0A1C38" fill-opacity="0.9"/>
</svg>

After

Width:  |  Height:  |  Size: 902 B

3
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties

@ -1234,6 +1234,9 @@ CellOtherSetPane.height=$Component.defaultHeight
[style]Button.inToolbarRight = \
margin : 0,0,0,0
[style]Button.tabAction = \
toolbar.margin : 5,11,5,11
[style]ToolBar.topTools = \
background: #fff

Loading…
Cancel
Save