forked from fanruan/design
Browse Source
* commit 'bf86ef5bb21305c468b48003ad61c0f2056d64df': CHART-19488 日期轴的日期控件构建成字符串公式 REPORT-54122 设计器组件选中状态右侧弹窗改进 去掉无用输出 REPORT-54122 fix 无用import REPORT-54122 设计器组件选中状态右侧弹窗改进 REPORT-53175【10.0.18】组件背景分离为标题/背景/边框 REPORT-55090【组件背景分离】组件复用-标题图案的图片预览图,和交互文档里定的悬浮时出现删除按钮和不透明遮罩预期效果不同 REPORT-55071 【组件背景分离】组件复用-标题填充选择渐变色时,设置面板出现纵向滚动条,遮挡住了渐变色右侧颜色选择按钮 REPORT-55089 组件背景分离】组件复用-现在锁按钮在宽高值之间,锁定时,拖拽调整组件大小时,宽度值会变化成一个很长的小数 CHART-19824 图表切换面板交互修改 REPORT-53175【10.0.18】组件背景分离为标题/背景/边框 REPORT-54392 释放最近打开表单对象内存实现方式变更 REPORT-53949 UISpinner获取焦点后才可以滚动调整值research/11.0
superman
3 years ago
28 changed files with 587 additions and 188 deletions
@ -1,5 +0,0 @@
|
||||
package com.fr.design.file; |
||||
|
||||
public interface Releasable { |
||||
void releaseResources(); |
||||
} |
@ -0,0 +1,148 @@
|
||||
package com.fr.env.utils; |
||||
|
||||
import com.fr.common.annotations.Compatible; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.EncodeConstants; |
||||
import com.fr.stable.ProductConstants; |
||||
import com.fr.stable.StableUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLReadable; |
||||
import com.fr.stable.xml.XMLTools; |
||||
import com.fr.stable.xml.XMLWriter; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
import com.fr.third.javax.xml.stream.XMLStreamException; |
||||
|
||||
import java.io.BufferedWriter; |
||||
import java.io.ByteArrayInputStream; |
||||
import java.io.ByteArrayOutputStream; |
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.FileNotFoundException; |
||||
import java.io.FileOutputStream; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.io.InputStreamReader; |
||||
import java.io.OutputStreamWriter; |
||||
import java.io.UnsupportedEncodingException; |
||||
import java.nio.charset.StandardCharsets; |
||||
|
||||
/** |
||||
* @author Starryi |
||||
* @version 10.0.18 |
||||
* Created by Starryi on 2021/7/7 |
||||
* 设计器访问和获取关键历史交互信息的持久化工具,该关键历史交互信息, |
||||
* 如用户是否点击过某按钮,是否查看过某弹窗信息,上次选择过的文件所在目录等 |
||||
*/ |
||||
@Compatible |
||||
public class DesignerInteractionHistory implements XMLReadable, XMLWriter { |
||||
|
||||
private static final String FILE_NAME = "designer.ix.history.info"; |
||||
private static final String ROOT_TAG = "History"; |
||||
|
||||
private static DesignerInteractionHistory history; |
||||
public static DesignerInteractionHistory getInstance() { |
||||
if (history == null) { |
||||
history = new DesignerInteractionHistory(); |
||||
|
||||
readXMLFile(history, history.getHistoryFile()); |
||||
} |
||||
|
||||
return history; |
||||
} |
||||
|
||||
private File getHistoryFile() { |
||||
return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME)); |
||||
} |
||||
|
||||
private static void readXMLFile(XMLReadable xmlReadable, File xmlFile) { |
||||
if (xmlFile == null || !xmlFile.exists()) { |
||||
return; |
||||
} |
||||
String charset = EncodeConstants.ENCODING_UTF_8; |
||||
try { |
||||
String decodeContent = getFileContent(xmlFile); |
||||
InputStream xmlInputStream = new ByteArrayInputStream(decodeContent.getBytes(charset)); |
||||
InputStreamReader inputStreamReader = new InputStreamReader(xmlInputStream, charset); |
||||
|
||||
XMLableReader xmlReader = XMLableReader.createXMLableReader(inputStreamReader); |
||||
|
||||
if (xmlReader != null) { |
||||
xmlReader.readXMLObject(xmlReadable); |
||||
} |
||||
xmlInputStream.close(); |
||||
} catch (IOException | XMLStreamException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
|
||||
} |
||||
|
||||
private static String getFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException { |
||||
InputStream encodeInputStream = new FileInputStream(xmlFile); |
||||
return IOUtils.inputStream2String(encodeInputStream); |
||||
} |
||||
|
||||
private static void writeContentToFile(String fileContent, File file) { |
||||
try (FileOutputStream fos = new FileOutputStream(file); |
||||
OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8); |
||||
BufferedWriter bw = new BufferedWriter(osw)) { |
||||
bw.write(fileContent); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
public void saveXMLFile() { |
||||
File xmlFile = this.getHistoryFile(); |
||||
try { |
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
||||
XMLTools.writeOutputStreamXML(this, out); |
||||
out.flush(); |
||||
out.close(); |
||||
String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); |
||||
writeContentToFile(fileContent, xmlFile); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
|
||||
private static final String HAS_SHOWN_SHIFT_DRAG_RESIZING_TOOLTIP = "hasShownShiftDragResizingTooltip"; |
||||
private static final String LAST_SELECTED_BORDER_IMAGE_DIR = "lastSelectedBorderImageDir"; |
||||
|
||||
// 是否已展示过按下Shift键可锁定比例拖拽尺寸的Tooltip
|
||||
private boolean hasShownShiftDragResizingTooltip = false; |
||||
// 用户上次通过文件选择器选择的边框图片所在目录
|
||||
private String lastSelectedBorderImageDir = StringUtils.EMPTY; |
||||
|
||||
public boolean isHasShownShiftDragResizingTooltip() { |
||||
return hasShownShiftDragResizingTooltip; |
||||
} |
||||
|
||||
public void setHasShownShiftDragResizingTooltip(boolean shown) { |
||||
this.hasShownShiftDragResizingTooltip = shown; |
||||
} |
||||
|
||||
public String getLastSelectedBorderImageDir() { |
||||
return lastSelectedBorderImageDir; |
||||
} |
||||
|
||||
public void setLastSelectedBorderImageDir(String dirPath) { |
||||
this.lastSelectedBorderImageDir = dirPath; |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
writer.startTAG(ROOT_TAG) |
||||
.attr(HAS_SHOWN_SHIFT_DRAG_RESIZING_TOOLTIP, isHasShownShiftDragResizingTooltip()) |
||||
.attr(LAST_SELECTED_BORDER_IMAGE_DIR, getLastSelectedBorderImageDir()) |
||||
.end(); |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
setHasShownShiftDragResizingTooltip(reader.getAttrAsBoolean(HAS_SHOWN_SHIFT_DRAG_RESIZING_TOOLTIP, false)); |
||||
setLastSelectedBorderImageDir(reader.getAttrAsString(LAST_SELECTED_BORDER_IMAGE_DIR, StringUtils.EMPTY)); |
||||
} |
||||
} |
After Width: | Height: | Size: 255 B |
After Width: | Height: | Size: 220 B |
@ -1,47 +0,0 @@
|
||||
package com.fr.design.designer.creator; |
||||
|
||||
import com.fr.design.form.util.XCreatorConstants; |
||||
import com.fr.general.IOUtils; |
||||
import java.awt.AlphaComposite; |
||||
import java.awt.Color; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Image; |
||||
import java.awt.Rectangle; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/06/30 |
||||
*/ |
||||
public class SelectedBorderIcon { |
||||
|
||||
private static final Image EDIT_ICON = IOUtils.readImage("/com/fr/design/images/control/show_edit.png"); |
||||
private static final Image SETTING_ICON = IOUtils.readImage("/com/fr/design/images/control/show_setting.png"); |
||||
private static final float ALPHA = 0.7F; |
||||
private static final int TIP_WIDTH = 20; |
||||
private static final int TIP_HEIGHT = 40; |
||||
private static final int ARC_VALUE = 4; |
||||
// 组件到整个提示之间的空隙
|
||||
private static final int CREATOR_TO_TIP_GAP = 5; |
||||
// icon在整个提示背景下缩进
|
||||
private static final int TIP_ICON_GAP = 2; |
||||
|
||||
/** |
||||
* 在bounds范围的右上角绘制特定图标 |
||||
* |
||||
* @param g |
||||
* @param bounds |
||||
*/ |
||||
public void paint(Graphics g, Rectangle bounds) { |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, ALPHA); |
||||
g2d.setColor(XCreatorConstants.EDIT_COLOR); |
||||
g2d.setComposite(alphaComposite); |
||||
g2d.fillRoundRect(bounds.x + bounds.width + CREATOR_TO_TIP_GAP, bounds.y, TIP_WIDTH, TIP_HEIGHT, ARC_VALUE, ARC_VALUE); |
||||
g2d.drawImage(EDIT_ICON, bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP, bounds.y + TIP_ICON_GAP, EDIT_ICON.getWidth(null), EDIT_ICON.getHeight(null), null); |
||||
g2d.drawImage(SETTING_ICON, bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP, bounds.y + CREATOR_TO_TIP_GAP + EDIT_ICON.getHeight(null), SETTING_ICON.getWidth(null), SETTING_ICON.getHeight(null), null); |
||||
g2d.setColor(Color.WHITE); |
||||
g2d.drawLine(bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP, bounds.y + TIP_WIDTH, bounds.x + bounds.width + CREATOR_TO_TIP_GAP + TIP_ICON_GAP + EDIT_ICON.getWidth(null), bounds.y + TIP_WIDTH); |
||||
} |
||||
} |
@ -0,0 +1,191 @@
|
||||
package com.fr.design.designer.ui; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.CoverReportPane; |
||||
import com.fr.design.mainframe.EditingMouseListener; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.stable.ArrayUtils; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Container; |
||||
import java.awt.Dimension; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Insets; |
||||
import java.awt.LayoutManager; |
||||
import java.awt.Rectangle; |
||||
import java.awt.RenderingHints; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseListener; |
||||
import javax.swing.AbstractButton; |
||||
import javax.swing.Icon; |
||||
import javax.swing.JButton; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JToggleButton; |
||||
import javax.swing.event.ChangeEvent; |
||||
import javax.swing.event.ChangeListener; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/7/8 |
||||
*/ |
||||
public class PopupControlPanel extends JPanel { |
||||
|
||||
private static final int ARC_VALUE = 4; |
||||
private static final Color FILLED_COLOR = new Color(60, 63, 65); |
||||
private static final int V_GAP = 10; |
||||
private static final int H_GAP = 2; |
||||
|
||||
private Dimension defaultDimension = new Dimension(20, 60); |
||||
private Rectangle rectangle; |
||||
private final JButton editButton; |
||||
private final JButton settingButton; |
||||
private final JToggleButton toggleButton; |
||||
private final XCreator creator; |
||||
private final UILabel firstLabel; |
||||
private final UILabel secondLabel; |
||||
|
||||
public PopupControlPanel(XCreator creator, FormDesigner designer) { |
||||
if (creator.isShared()) { |
||||
defaultDimension = new Dimension(20, 85); |
||||
} |
||||
setLayout(getCustomLayout()); |
||||
this.creator = creator; |
||||
editButton = createNormalButton(IOUtils.readIcon("/com/fr/design/images/control/show_edit.png"), Toolkit.i18nText("Fine-Design_Form_Edit_Widget")); |
||||
editButton.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
int x = rectangle.x + rectangle.width / 2; |
||||
int y = rectangle.y + rectangle.height / 2; |
||||
XCreator childCreator = PopupControlPanel.this.creator.getEditingChildCreator(); |
||||
MouseListener[] listeners = designer.getMouseListeners(); |
||||
if (ArrayUtils.isNotEmpty(listeners) && listeners[0] instanceof EditingMouseListener) { |
||||
childCreator.respondClick(((EditingMouseListener) listeners[0]), new MouseEvent(childCreator, MouseEvent.MOUSE_CLICKED, e.getWhen(), e.getModifiers(), x, y, 2, false)); |
||||
} |
||||
} |
||||
}); |
||||
settingButton = createNormalButton(IOUtils.readIcon("/com/fr/design/images/control/show_setting.png"), Toolkit.i18nText("Fine-Design_Share_Help_Settings")); |
||||
|
||||
settingButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
CoverReportPane.showShareConfig(creator.toData()); |
||||
} |
||||
}); |
||||
toggleButton = new JToggleButton(IOUtils.readIcon("/com/fr/design/images/control/edit_lock.png")); |
||||
initButtonStyle(toggleButton); |
||||
toggleButton.setSelectedIcon(IOUtils.readIcon("com/fr/design/images/control/edit_unlock.png")); |
||||
toggleButton.setToolTipText(Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio")); |
||||
toggleButton.addChangeListener(new ChangeListener() { |
||||
@Override |
||||
public void stateChanged(ChangeEvent e) { |
||||
JToggleButton toggleBtn = (JToggleButton) e.getSource(); |
||||
String toolTipText = toggleBtn.isSelected() ? Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio") : Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio"); |
||||
toggleBtn.setToolTipText(toolTipText); |
||||
} |
||||
}); |
||||
|
||||
firstLabel = createLabel(); |
||||
secondLabel = createLabel(); |
||||
|
||||
add(editButton); |
||||
add(toggleButton); |
||||
add(settingButton); |
||||
add(firstLabel); |
||||
add(secondLabel); |
||||
} |
||||
|
||||
protected LayoutManager getCustomLayout() { |
||||
return new LayoutManager() { |
||||
|
||||
@Override |
||||
public void removeLayoutComponent(Component comp) { |
||||
} |
||||
|
||||
@Override |
||||
public Dimension preferredLayoutSize(Container parent) { |
||||
return defaultDimension; |
||||
} |
||||
|
||||
@Override |
||||
public Dimension minimumLayoutSize(Container parent) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void layoutContainer(Container parent) { |
||||
int width = parent.getPreferredSize().width; |
||||
int buttonWidth = editButton.getPreferredSize().width; |
||||
int buttonHeight = editButton.getPreferredSize().height; |
||||
int x = (width - buttonWidth) / 2; |
||||
editButton.setBounds(x, V_GAP, buttonWidth, buttonHeight); |
||||
firstLabel.setBounds(x, V_GAP + editButton.getHeight() + V_GAP / 2, buttonWidth, buttonHeight); |
||||
toggleButton.setBounds(x, V_GAP * 2 + editButton.getHeight(), buttonWidth, buttonHeight); |
||||
if (creator.isShared()) { |
||||
secondLabel.setBounds(x, V_GAP * 2 + editButton.getHeight() + toggleButton.getHeight() + V_GAP / 2, buttonWidth, buttonHeight); |
||||
settingButton.setBounds(x, V_GAP * 3 + editButton.getHeight() + toggleButton.getHeight(), buttonWidth, buttonHeight); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void addLayoutComponent(String name, Component comp) { |
||||
} |
||||
}; |
||||
} |
||||
|
||||
private JButton createNormalButton(Icon icon, String toolTipText) { |
||||
JButton button = new JButton(icon); |
||||
initButtonStyle(button); |
||||
button.setToolTipText(toolTipText); |
||||
return button; |
||||
} |
||||
|
||||
private void initButtonStyle(AbstractButton button) { |
||||
button.setBorderPainted(false); |
||||
button.setBorder(null); |
||||
button.setMargin(new Insets(0, 0, 0, 0)); |
||||
button.setContentAreaFilled(false); |
||||
} |
||||
|
||||
private UILabel createLabel() { |
||||
return new UILabel() { |
||||
@Override |
||||
public void paint(Graphics g) { |
||||
super.paint(g); |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
g2d.setColor(Color.WHITE); |
||||
g2d.drawLine(H_GAP, 0, toggleButton.getWidth() - H_GAP, 0); |
||||
|
||||
} |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
protected void paintComponent(Graphics g) { |
||||
super.paintComponent(g); |
||||
int w = this.getWidth(); |
||||
int h = this.getHeight(); |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
||||
g2d.setColor(FILLED_COLOR); |
||||
g2d.fillRoundRect(0, 0, w - 1, h - 1, ARC_VALUE, ARC_VALUE); |
||||
g2d.setColor(Color.WHITE); |
||||
g2d.drawRoundRect(0, 0, w - 1, h - 1, ARC_VALUE, ARC_VALUE); |
||||
} |
||||
|
||||
public Dimension getDefaultDimension() { |
||||
return defaultDimension; |
||||
} |
||||
|
||||
public void setRelativeBounds(Rectangle rectangle) { |
||||
this.rectangle = rectangle; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.design.designer.ui; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import java.awt.Rectangle; |
||||
import javax.swing.JDialog; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/7/09 |
||||
*/ |
||||
public class SelectedPopupDialog extends JDialog { |
||||
|
||||
/** |
||||
* 弹窗的相对组件的偏移 |
||||
*/ |
||||
public static final int OFFSET_X = 5; |
||||
|
||||
private final PopupControlPanel controlPanel; |
||||
|
||||
public SelectedPopupDialog(XCreator creator, FormDesigner designer) { |
||||
super(DesignerContext.getDesignerFrame()); |
||||
this.setUndecorated(true); |
||||
this.setModal(false); |
||||
controlPanel = new PopupControlPanel(creator, designer); |
||||
this.getContentPane().add(controlPanel); |
||||
this.setSize(controlPanel.getDefaultDimension()); |
||||
} |
||||
|
||||
public void setRelativeBounds(Rectangle rectangle) { |
||||
this.controlPanel.setRelativeBounds(rectangle); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,7 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
|
||||
public interface XCreateGather { |
||||
void dealWith(XCreator xCreator); |
||||
} |
Loading…
Reference in new issue