@ -0,0 +1,35 @@ |
|||||||
|
package com.fr.design.designer.beans; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
public class PredefinedLayout implements Serializable { |
||||||
|
private static final String IMAGE_PATH = "/com/fr/design/form/layouts/images/"; |
||||||
|
private static final String TEMPLATE_PATH = "/com/fr/design/form/layouts/templates/"; |
||||||
|
private String template; |
||||||
|
private String realStyle; |
||||||
|
private String simpleStyle; |
||||||
|
|
||||||
|
public String getTemplate() { |
||||||
|
return TEMPLATE_PATH + template; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTemplate(String template) { |
||||||
|
this.template = template; |
||||||
|
} |
||||||
|
|
||||||
|
public String getRealStyle() { |
||||||
|
return IMAGE_PATH + realStyle; |
||||||
|
} |
||||||
|
|
||||||
|
public void setRealStyle(String realStyle) { |
||||||
|
this.realStyle = realStyle; |
||||||
|
} |
||||||
|
|
||||||
|
public String getSimpleStyle() { |
||||||
|
return IMAGE_PATH + simpleStyle; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSimpleStyle(String simpleStyle) { |
||||||
|
this.simpleStyle = simpleStyle; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
package com.fr.design.designer.beans.actions.behavior; |
||||||
|
|
||||||
|
import com.fr.design.designer.beans.actions.FormWidgetEditAction; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
|
||||||
|
public class PasteEnable implements UpdateBehavior<FormWidgetEditAction> { |
||||||
|
@Override |
||||||
|
public void doUpdate(FormWidgetEditAction action) { |
||||||
|
FormDesigner designer = action.getEditingComponent(); |
||||||
|
if (designer == null) { |
||||||
|
action.setEnabled(false); |
||||||
|
return; |
||||||
|
} |
||||||
|
action.setEnabled(designer.isCurrentComponentPastable()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
package com.fr.design.designer.beans.adapters.layout; |
||||||
|
|
||||||
|
public class DefaultDesignerBaseOperate implements DesignerBaseOperate{ |
||||||
|
@Override |
||||||
|
public boolean supportCopyAction() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportCutAction() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportPasteAction() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportDeleteAction() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
package com.fr.design.designer.beans.adapters.layout; |
||||||
|
|
||||||
|
public interface DesignerBaseOperate { |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否支持复制 |
||||||
|
* |
||||||
|
* @return boolean |
||||||
|
*/ |
||||||
|
boolean supportCopyAction(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否支持剪切 |
||||||
|
* |
||||||
|
* @return boolean |
||||||
|
*/ |
||||||
|
boolean supportCutAction(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否支持粘贴 |
||||||
|
* |
||||||
|
* @return boolean |
||||||
|
*/ |
||||||
|
boolean supportPasteAction(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否支持删除 |
||||||
|
* |
||||||
|
* @return boolean |
||||||
|
*/ |
||||||
|
boolean supportDeleteAction(); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,138 @@ |
|||||||
|
package com.fr.design.designer.beans.adapters.layout; |
||||||
|
|
||||||
|
import com.fr.base.svg.IconUtils; |
||||||
|
import com.fr.design.designer.beans.HoverPainter; |
||||||
|
import com.fr.design.designer.beans.models.ModelUtil; |
||||||
|
import com.fr.design.designer.beans.models.SelectionModel; |
||||||
|
import com.fr.design.designer.beans.painters.FRFixLayoutPainter; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.designer.creator.XLayoutContainer; |
||||||
|
import com.fr.design.designer.creator.XOccupiedLayout; |
||||||
|
import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender; |
||||||
|
import com.fr.design.designer.treeview.XCreatorTreeCellRender; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.design.mainframe.WidgetPropertyPane; |
||||||
|
import com.fr.form.ui.container.OccupiedLayout; |
||||||
|
import javax.swing.Icon; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.Graphics; |
||||||
|
|
||||||
|
public class FRFixLayoutAdapter extends AbstractLayoutAdapter { |
||||||
|
private static final Icon OCCUPIED_ICON = IconUtils.readIcon("/com/fr/design/form/images/occupied_layout.png"); |
||||||
|
|
||||||
|
public FRFixLayoutAdapter( XLayoutContainer container) { |
||||||
|
super(container); |
||||||
|
} |
||||||
|
|
||||||
|
public void addComp(XCreator child, int x, int y) { |
||||||
|
Component component = container.getComponentAt(x, y); |
||||||
|
if (component == container) { |
||||||
|
return; |
||||||
|
} |
||||||
|
child.setLocation(component.getX(), component.getY()); |
||||||
|
child.setSize(component.getWidth(), component.getHeight()); |
||||||
|
if (child.shouldScaleCreator() || child.hasTitleStyle()) { |
||||||
|
XLayoutContainer parentPanel = child.initCreatorWrapper(21); |
||||||
|
container.replaceXcreator(parentPanel, (XCreator) component); |
||||||
|
} else { |
||||||
|
container.replaceXcreator(child, (XCreator) component); |
||||||
|
} |
||||||
|
if (child.getBackupRectangle() != null && child.getParent() == container) { |
||||||
|
Component origin = container.getComponentAt(child.getBackupRectangle().x + 5, child.getBackupRectangle().y + 5); |
||||||
|
if (origin == container) { |
||||||
|
return; |
||||||
|
} |
||||||
|
if (origin instanceof XOccupiedLayout) { |
||||||
|
((XOccupiedLayout) origin).getLayoutAdapter().addBean((XCreator) component, child.getBackupRectangle().x + 5, child.getBackupRectangle().y + 5); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void delete(XCreator creator, int creatorWidth, int creatorHeight) { |
||||||
|
//固定布局下不支持移除占位块组件
|
||||||
|
if (creator.acceptType(XOccupiedLayout.class)){ |
||||||
|
return; |
||||||
|
} |
||||||
|
OccupiedLayout occupiedLayout = new OccupiedLayout(); |
||||||
|
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
||||||
|
XOccupiedLayout xoccupiedLayout = new XOccupiedLayout(occupiedLayout, new Dimension()); |
||||||
|
ModelUtil.renameWidgetName(formDesigner.getTarget(), xoccupiedLayout); |
||||||
|
xoccupiedLayout.setLocation(creator.getX(), creator.getY()); |
||||||
|
xoccupiedLayout.setSize(creatorWidth, creatorHeight); |
||||||
|
container.replaceXcreator(xoccupiedLayout,creator); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator) { |
||||||
|
return new DefaultXCreatorTreeCellRender(creator) { |
||||||
|
@Override |
||||||
|
public void paint(Graphics g, Component c) { |
||||||
|
if (!getxCreator().acceptType(XOccupiedLayout.class)) { |
||||||
|
OCCUPIED_ICON.paintIcon(c, g, 0, 0); |
||||||
|
} |
||||||
|
super.paint(g, c); |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportModifyInsert() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DesignerBaseOperate getDesignerBaseOperate() { |
||||||
|
return new DesignerBaseOperate() { |
||||||
|
@Override |
||||||
|
public boolean supportCopyAction() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportCutAction() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportPasteAction() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportDeleteAction() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean accept(XCreator creator, int x, int y) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public HoverPainter getPainter() { |
||||||
|
return new FRFixLayoutPainter(container); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void dragStart(XCreator xCreator, SelectionModel selectionModel) { |
||||||
|
//do nothing
|
||||||
|
} |
||||||
|
|
||||||
|
public void dragOver(XCreator xCreator, SelectionModel selectionModel, int x, int y) { |
||||||
|
//当鼠标移出被拖拽的组件时,才将组件从selectionmodel 中移出
|
||||||
|
if (xCreator.getBackupRectangle()!= null && !xCreator.getBackupRectangle().contains(x, y) |
||||||
|
&& selectionModel.getSelection().contains(xCreator.toData())) { |
||||||
|
selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight()); |
||||||
|
selectionModel.setSelectedCreator(container); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
; |
||||||
|
} |
@ -0,0 +1,116 @@ |
|||||||
|
package com.fr.design.designer.beans.adapters.layout; |
||||||
|
|
||||||
|
import com.fr.design.designer.beans.models.SelectionModel; |
||||||
|
import com.fr.design.designer.beans.painters.AbstractPainter; |
||||||
|
import com.fr.design.designer.beans.painters.FRFitLayoutPainter; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.designer.creator.XLayoutContainer; |
||||||
|
import com.fr.design.designer.creator.XWFitLayout; |
||||||
|
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; |
||||||
|
|
||||||
|
import java.awt.Component; |
||||||
|
import java.util.ArrayList; |
||||||
|
|
||||||
|
public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter { |
||||||
|
private int minHeight; |
||||||
|
private FRBodyLayoutAdapter parentLayoutAdapter; |
||||||
|
|
||||||
|
public FRNoFixLayoutAdapter(FRBodyLayoutAdapter parentLayoutAdapter, XLayoutContainer container, int minHeight) { |
||||||
|
super(container); |
||||||
|
this.parentLayoutAdapter = parentLayoutAdapter; |
||||||
|
this.minHeight = minHeight; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void addComp(XCreator child, int x, int y) { |
||||||
|
fix(child, x, y); |
||||||
|
if (child.shouldScaleCreator() || child.hasTitleStyle()) { |
||||||
|
addParentCreator(child); |
||||||
|
} else { |
||||||
|
container.add(child, child.toData().getWidgetName()); |
||||||
|
} |
||||||
|
XWFitLayout layout = (XWFitLayout) container; |
||||||
|
// 更新对应的BoundsWidget
|
||||||
|
layout.updateBoundsWidget(); |
||||||
|
updateCreatorBackBound(); |
||||||
|
} |
||||||
|
|
||||||
|
private void updateCreatorBackBound() { |
||||||
|
for (int i = 0, size = container.getComponentCount(); i < size; i++) { |
||||||
|
XCreator creator = (XCreator) container.getComponent(i); |
||||||
|
creator.updateChildBound(minHeight); |
||||||
|
creator.setBackupBound(creator.getBounds()); |
||||||
|
//tab布局用到
|
||||||
|
ArrayList<?> childrenList = creator.getTargetChildrenList(); |
||||||
|
for (int j = 0; j < childrenList.size(); j++) { |
||||||
|
XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList.get(j); |
||||||
|
for (int m = 0; m < tabLayout.getComponentCount(); m++) { |
||||||
|
XCreator childCreator = tabLayout.getXCreator(m); |
||||||
|
childCreator.setBackupBound(childCreator.getBounds()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void addParentCreator(XCreator child) { |
||||||
|
XLayoutContainer parentPanel = child.initCreatorWrapper(minHeight); |
||||||
|
container.add(parentPanel, child.toData().getWidgetName()); |
||||||
|
} |
||||||
|
|
||||||
|
private void fix(XCreator child, int x, int y) { |
||||||
|
Component parentComp = container.getComponentAt(x, y); |
||||||
|
if (container.getComponentCount() == 0) { |
||||||
|
child.setLocation(0, 0); |
||||||
|
child.setSize(parentComp.getWidth(), parentComp.getHeight()); |
||||||
|
} else if (parentLayoutAdapter.isCrossPointArea(parentComp, x, y)) { |
||||||
|
//交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入
|
||||||
|
parentLayoutAdapter.fixCrossPointArea(parentComp, child, x, y); |
||||||
|
return; |
||||||
|
} else if (parentLayoutAdapter.isTrisectionArea(parentComp, x, y)) { |
||||||
|
// 在边界三等分区域,就不再和组件二等分了
|
||||||
|
parentLayoutAdapter.fixTrisect(parentComp, child, x, y); |
||||||
|
return; |
||||||
|
} else { |
||||||
|
parentLayoutAdapter.fixHalve(parentComp, child, x, y); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void delete(XCreator creator, int creatorWidth, int creatorHeight) { |
||||||
|
int x = creator.getX(); |
||||||
|
int y = creator.getY(); |
||||||
|
((FRFitLayoutAdapter)parentLayoutAdapter).recalculateChildrenSize(x, y, creatorWidth, creatorHeight, true); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportModifyInsert() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DesignerBaseOperate getDesignerBaseOperate() { |
||||||
|
return new DefaultDesignerBaseOperate() { |
||||||
|
@Override |
||||||
|
public boolean supportCutAction() { |
||||||
|
return container.getComponentCount() > 1; |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean accept(XCreator creator, int x, int y) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public AbstractPainter getPainter() { |
||||||
|
return new FRFitLayoutPainter(container); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void dragStart(XCreator xCreator, SelectionModel selectionModel) { |
||||||
|
selectionModel.removeCreator(xCreator, xCreator.getWidth(), xCreator.getHeight()); |
||||||
|
selectionModel.setSelectedCreator(container); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
package com.fr.design.designer.beans.adapters.layout; |
||||||
|
|
||||||
|
import com.fr.design.designer.beans.HoverPainter; |
||||||
|
import com.fr.design.designer.beans.painters.FROccupiedLayoutPainter; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.designer.creator.XLayoutContainer; |
||||||
|
import com.fr.design.designer.treeview.DefaultXCreatorTreeCellRender; |
||||||
|
import com.fr.design.designer.treeview.XCreatorTreeCellRender; |
||||||
|
import com.fr.design.utils.gui.LayoutUtils; |
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Graphics; |
||||||
|
|
||||||
|
public class FROccupiedLayoutAdapter extends AbstractLayoutAdapter { |
||||||
|
|
||||||
|
public FROccupiedLayoutAdapter(XLayoutContainer container) { |
||||||
|
super(container); |
||||||
|
painter = new FROccupiedLayoutPainter(container); |
||||||
|
} |
||||||
|
|
||||||
|
private HoverPainter painter; |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
protected void addComp(XCreator creator, int x, int y) { |
||||||
|
if (container.getComponentCount() == 0) { |
||||||
|
creator.setLocation(container.getLocation().x, container.getLocation().y); |
||||||
|
creator.setSize(container.getWidth(), container.getHeight()); |
||||||
|
XLayoutContainer parent = (XLayoutContainer) container.getParent(); |
||||||
|
if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { |
||||||
|
XLayoutContainer parentPanel = creator.initCreatorWrapper(21); |
||||||
|
parent.replaceXcreator(parentPanel, container); |
||||||
|
} else { |
||||||
|
parent.replaceXcreator(creator, container); |
||||||
|
} |
||||||
|
LayoutUtils.layoutContainer(parent); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public HoverPainter getPainter() { |
||||||
|
return painter; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean accept(XCreator creator, int x, int y) { |
||||||
|
return container.getComponentCount() == 0; |
||||||
|
} |
||||||
|
|
||||||
|
public XCreatorTreeCellRender getLayoutTreeCellRender(XCreator creator) { |
||||||
|
return new DefaultXCreatorTreeCellRender(creator) { |
||||||
|
@Override |
||||||
|
public void paint(Graphics g, Component c) { |
||||||
|
super.paint(g, c); |
||||||
|
Color oldColor = g.getColor(); |
||||||
|
g.setColor(Color.RED); |
||||||
|
g.drawRect(0, 0, 16, 16); |
||||||
|
g.setColor(oldColor); |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
package com.fr.design.designer.beans.models; |
||||||
|
|
||||||
|
import com.fr.design.designer.beans.PredefinedLayout; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.third.fasterxml.jackson.databind.ObjectMapper; |
||||||
|
|
||||||
|
import java.io.InputStream; |
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public class NewFormModel implements Serializable { |
||||||
|
private static final String CONFIG_FILE_PATH = "/com/fr/design/form/layouts/config.json"; |
||||||
|
private static NewFormModel holder = null; |
||||||
|
private Map<String, List<PredefinedLayout>> config = new HashMap<>(); |
||||||
|
|
||||||
|
public static NewFormModel getInstance() { |
||||||
|
if (holder == null) { |
||||||
|
try { |
||||||
|
holder = new ObjectMapper().readValue(readConfigFile(), NewFormModel.class); |
||||||
|
} catch (Exception e) { |
||||||
|
holder = new NewFormModel(); |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
return holder; |
||||||
|
} |
||||||
|
|
||||||
|
private NewFormModel() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private synchronized static String readConfigFile() { |
||||||
|
String result = StringUtils.EMPTY; |
||||||
|
InputStream is = null; |
||||||
|
try { |
||||||
|
is = IOUtils.readResource(CONFIG_FILE_PATH); |
||||||
|
result = IOUtils.inputStream2String(is); |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} finally { |
||||||
|
IOUtils.close(is); |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
public Map<String, List<PredefinedLayout>> getConfig() { |
||||||
|
return config; |
||||||
|
} |
||||||
|
|
||||||
|
public void setConfig(Map<String, List<PredefinedLayout>> config) { |
||||||
|
this.config = config; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,130 @@ |
|||||||
|
package com.fr.design.designer.beans.painters; |
||||||
|
|
||||||
|
import com.fr.design.designer.beans.painters.AbstractPainter; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.designer.creator.XLayoutContainer; |
||||||
|
import com.fr.design.designer.creator.XOccupiedLayout; |
||||||
|
import com.fr.design.form.util.XCreatorConstants; |
||||||
|
|
||||||
|
import java.awt.AlphaComposite; |
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Composite; |
||||||
|
import java.awt.Graphics; |
||||||
|
import java.awt.Graphics2D; |
||||||
|
import java.awt.Rectangle; |
||||||
|
import java.awt.Stroke; |
||||||
|
|
||||||
|
public class FRFixLayoutPainter extends AbstractPainter { |
||||||
|
|
||||||
|
/** |
||||||
|
* 构造函数 |
||||||
|
* |
||||||
|
* @param container |
||||||
|
*/ |
||||||
|
public FRFixLayoutPainter(XLayoutContainer container) { |
||||||
|
super(container); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 组件渲染 |
||||||
|
* |
||||||
|
* @param g 画图类 |
||||||
|
* @param startX 开始位置x |
||||||
|
* @param startY 开始位置y |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void paint(Graphics g, int startX, int startY) { |
||||||
|
super.paint(g, startX, startY); |
||||||
|
int x = hotspot.x - hotspot_bounds.x; |
||||||
|
int y = hotspot.y - hotspot_bounds.y; |
||||||
|
Component currentComp = container.getComponentAt(x, y); |
||||||
|
if (currentComp == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
boolean accept = currentComp != container; |
||||||
|
if (accept) { |
||||||
|
OperateState state = OperateState.DEFAULT; |
||||||
|
if (currentComp == creator) { |
||||||
|
state = OperateState.COMPONENT_DRAG_OUT; |
||||||
|
} else if (!((XCreator) currentComp).acceptType(XOccupiedLayout.class)) { |
||||||
|
state = OperateState.COMPONENT_REPLACE; |
||||||
|
} |
||||||
|
state.paint(g, creator.getBackupRectangle(), currentComp.getBounds(), new Rectangle(x, y, creator.initEditorSize().width, ((XCreator) currentComp).initEditorSize().height)); |
||||||
|
} else { |
||||||
|
Color bColor = XCreatorConstants.LAYOUT_FORBIDDEN_COLOR; |
||||||
|
int[] hot_rec = new int[]{x, y, 0, 0}; |
||||||
|
drawHotspot(g, x, y, hot_rec[2], hot_rec[3], bColor, false, false); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
enum OperateState { |
||||||
|
COMPONENT_REPLACE { |
||||||
|
@Override |
||||||
|
void paint(Graphics g, Rectangle oriRectangle, Rectangle currentRectangle, Rectangle hotspot_bounds) { |
||||||
|
Graphics2D g2d = (Graphics2D) g; |
||||||
|
Color color = g2d.getColor(); |
||||||
|
Stroke backup = g2d.getStroke(); |
||||||
|
Composite backupComp = g2d.getComposite(); |
||||||
|
|
||||||
|
g2d.setColor(XCreatorConstants.REPLACE_OCCUPIED_LAYOUT_COLOR); |
||||||
|
g2d.setStroke(XCreatorConstants.DASH_STROKE); |
||||||
|
//绘制当前组件的边框
|
||||||
|
g2d.drawRect(currentRectangle.x, currentRectangle.y, currentRectangle.width, currentRectangle.height); |
||||||
|
//底色透明度0.2
|
||||||
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f)); |
||||||
|
//绘制进行替换的时候,被替换的组件的底色
|
||||||
|
g2d.fillRect(currentRectangle.x, currentRectangle.y, currentRectangle.width, currentRectangle.height); |
||||||
|
|
||||||
|
//绘制原组件位置处的占位块
|
||||||
|
if (oriRectangle != null) { |
||||||
|
g2d.setColor(XCreatorConstants.DRAG_OUT_OCCUPIED_LAYOUT_COLOR); |
||||||
|
//如果是从其他占位块上拖过来的,绘制下其他占位块的状态
|
||||||
|
g2d.drawRect(oriRectangle.x + 1, oriRectangle.y + 1, oriRectangle.width - 2, oriRectangle.height - 2); |
||||||
|
//底色透明度0.2
|
||||||
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f)); |
||||||
|
//绘制进行替换的时候,被替换的组件的底色
|
||||||
|
g2d.fillRect(oriRectangle.x, oriRectangle.y, oriRectangle.width, oriRectangle.height); |
||||||
|
} |
||||||
|
//还原
|
||||||
|
g2d.setComposite(backupComp); |
||||||
|
g2d.setStroke(backup); |
||||||
|
g2d.setColor(color); |
||||||
|
} |
||||||
|
}, |
||||||
|
COMPONENT_DRAG_OUT { |
||||||
|
@Override |
||||||
|
void paint(Graphics g, Rectangle oriRectangle, Rectangle currentRectangle, Rectangle hotspot_bounds) { |
||||||
|
Graphics2D g2d = (Graphics2D) g; |
||||||
|
Color color = g2d.getColor(); |
||||||
|
Stroke backup = g2d.getStroke(); |
||||||
|
Composite backupComp = g2d.getComposite(); |
||||||
|
// 设置线条的样式
|
||||||
|
g2d.setStroke(XCreatorConstants.DASH_STROKE); |
||||||
|
g2d.setColor(XCreatorConstants.DRAG_OUT_OCCUPIED_LAYOUT_COLOR); |
||||||
|
//如果是从其他占位块上拖过来的,绘制下其他占位块的状态
|
||||||
|
g2d.drawRect(oriRectangle.x, oriRectangle.y, oriRectangle.width, oriRectangle.height); |
||||||
|
//底色透明度0.2
|
||||||
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f)); |
||||||
|
//绘制进行替换的时候,被替换的组件的底色
|
||||||
|
g2d.fillRect(oriRectangle.x, oriRectangle.y, oriRectangle.width, oriRectangle.height); |
||||||
|
|
||||||
|
g2d.setComposite(backupComp); |
||||||
|
g2d.setStroke(backup); |
||||||
|
g2d.setColor(color); |
||||||
|
} |
||||||
|
}, |
||||||
|
DEFAULT { |
||||||
|
@Override |
||||||
|
void paint(Graphics g, Rectangle oriRectangle, Rectangle currentRectangle, Rectangle hotspot_bounds) { |
||||||
|
|
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
abstract void paint(Graphics g, Rectangle oriRectangle, Rectangle currentRectangle, Rectangle hotspot_bounds); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,56 @@ |
|||||||
|
package com.fr.design.designer.beans.painters; |
||||||
|
|
||||||
|
import com.fr.design.designer.beans.adapters.layout.FROccupiedLayoutAdapter; |
||||||
|
import com.fr.design.designer.creator.XLayoutContainer; |
||||||
|
import com.fr.design.form.util.XCreatorConstants; |
||||||
|
|
||||||
|
import java.awt.AlphaComposite; |
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Composite; |
||||||
|
import java.awt.Graphics; |
||||||
|
import java.awt.Graphics2D; |
||||||
|
import java.awt.Stroke; |
||||||
|
|
||||||
|
public class FROccupiedLayoutPainter extends AbstractPainter { |
||||||
|
|
||||||
|
/** |
||||||
|
* 构造函数 |
||||||
|
* |
||||||
|
* @param container 容器 |
||||||
|
*/ |
||||||
|
public FROccupiedLayoutPainter(XLayoutContainer container) { |
||||||
|
super(container); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paint(Graphics g, int startX, int startY) { |
||||||
|
int x = hotspot.x - hotspot_bounds.x; |
||||||
|
int y = hotspot.y - hotspot_bounds.y; |
||||||
|
FROccupiedLayoutAdapter adapter = (FROccupiedLayoutAdapter) container.getLayoutAdapter(); |
||||||
|
Component currentComp = container.getComponentAt(x, y); |
||||||
|
if (currentComp == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
boolean accept = adapter.accept(creator, x, y); |
||||||
|
if (accept) { |
||||||
|
Color backupColor = g.getColor(); |
||||||
|
Graphics2D g2d = (Graphics2D) g; |
||||||
|
Stroke backupStroke = g2d.getStroke(); |
||||||
|
Composite backupComposite = g2d.getComposite(); |
||||||
|
g2d.setColor(XCreatorConstants.DRAG_IN_OCCUPIED_LAYOUT_COLOR); |
||||||
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.05f)); |
||||||
|
g2d.fillRect(container.getX(), container.getY(), container.getWidth(), container.getHeight()); |
||||||
|
|
||||||
|
g2d.setStroke(XCreatorConstants.DASH_STROKE); |
||||||
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f)); |
||||||
|
g2d.drawRect(container.getX() + 1, container.getY() + 1, container.getWidth() - 2, container.getHeight() - 2); |
||||||
|
g2d.setStroke(backupStroke); |
||||||
|
g2d.setComposite(backupComposite); |
||||||
|
g2d.setColor(backupColor); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,81 @@ |
|||||||
|
package com.fr.design.designer.creator; |
||||||
|
|
||||||
|
import com.fr.design.designer.beans.LayoutAdapter; |
||||||
|
import com.fr.design.designer.beans.adapters.layout.FROccupiedLayoutAdapter; |
||||||
|
import com.fr.design.designer.creator.operate.DefaultXCreatorBaseOperate; |
||||||
|
import com.fr.design.designer.creator.operate.XCreatorBaseOperate; |
||||||
|
import com.fr.design.form.layout.FRFitLayout; |
||||||
|
import com.fr.design.form.util.XCreatorConstants; |
||||||
|
import com.fr.form.ui.container.OccupiedLayout; |
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.Graphics; |
||||||
|
import java.awt.Graphics2D; |
||||||
|
import java.awt.Stroke; |
||||||
|
|
||||||
|
public class XOccupiedLayout extends XLayoutContainer { |
||||||
|
|
||||||
|
public XOccupiedLayout() { |
||||||
|
this(new OccupiedLayout(), new Dimension()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public XOccupiedLayout(OccupiedLayout widget, Dimension initSize) { |
||||||
|
super(widget, initSize); |
||||||
|
initLayoutManager(); |
||||||
|
} |
||||||
|
|
||||||
|
public String createDefaultName() { |
||||||
|
return "box"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void initLayoutManager() { |
||||||
|
this.setLayout(new FRFitLayout()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public LayoutAdapter getLayoutAdapter() { |
||||||
|
return new FROccupiedLayoutAdapter(this); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public String getIconPath() { |
||||||
|
return "/com/fr/design/form/images/occupied_layout.png"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isComponentTreeLeaf() { |
||||||
|
//在控件树上表现为叶子节点(组件放置到占位块中的时候,会删除占位块,只展示组件)
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public XCreatorBaseOperate getXCreatorBaseOperate() { |
||||||
|
return new DefaultXCreatorBaseOperate() { |
||||||
|
@Override |
||||||
|
public boolean supportSelected() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void paint(Graphics g) { |
||||||
|
drawOccupiedComponentBounds(g); |
||||||
|
} |
||||||
|
|
||||||
|
private void drawOccupiedComponentBounds(Graphics g) { |
||||||
|
Graphics2D g2d = (Graphics2D) g; |
||||||
|
Color color = g2d.getColor(); |
||||||
|
Stroke backup = g2d.getStroke(); |
||||||
|
// 设置线条的样式
|
||||||
|
g2d.setStroke(XCreatorConstants.DASH_STROKE); |
||||||
|
g2d.setColor(XCreatorConstants.EMPTY_OCCUPIED_LAYOUT_COLOR); |
||||||
|
g2d.drawRect(1, 1, this.getWidth() - 2, this.getHeight() - 2); |
||||||
|
g2d.setStroke(backup); |
||||||
|
g2d.setColor(color); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
package com.fr.design.designer.creator.operate; |
||||||
|
|
||||||
|
|
||||||
|
public class DefaultXCreatorBaseOperate implements XCreatorBaseOperate { |
||||||
|
@Override |
||||||
|
public boolean supportSelected() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportCopyAction() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportCutAction() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportPasteAction() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean supportDeleteAction() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
package com.fr.design.designer.creator.operate; |
||||||
|
|
||||||
|
import com.fr.design.designer.beans.adapters.layout.DesignerBaseOperate; |
||||||
|
|
||||||
|
public interface XCreatorBaseOperate extends DesignerBaseOperate { |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否支持选中 |
||||||
|
* |
||||||
|
* @return boolean |
||||||
|
*/ |
||||||
|
boolean supportSelected(); |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
package com.fr.design.designer.treeview; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.mainframe.share.util.ShareComponentUtils; |
||||||
|
|
||||||
|
import javax.swing.Icon; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Graphics; |
||||||
|
|
||||||
|
public class DefaultXCreatorTreeCellRender implements XCreatorTreeCellRender { |
||||||
|
private static final Icon SHARE_ICON = BaseUtils.readIcon("/com/fr/design/images/toast/reuse_icon.png"); |
||||||
|
private XCreator xCreator; |
||||||
|
|
||||||
|
public DefaultXCreatorTreeCellRender(XCreator creator) { |
||||||
|
this.xCreator = creator; |
||||||
|
} |
||||||
|
|
||||||
|
public XCreator getxCreator(){ |
||||||
|
return xCreator; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paint(Graphics g, Component c) { |
||||||
|
if (ShareComponentUtils.isShareWidgetWithChild( xCreator)) { |
||||||
|
SHARE_ICON.paintIcon(c, g, 10, 0); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,8 @@ |
|||||||
|
package com.fr.design.designer.treeview; |
||||||
|
|
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Graphics; |
||||||
|
|
||||||
|
public interface XCreatorTreeCellRender { |
||||||
|
void paint(Graphics g, Component c); |
||||||
|
} |
@ -1,114 +0,0 @@ |
|||||||
package com.fr.design.fit.attrpane; |
|
||||||
|
|
||||||
import com.fr.base.theme.FormTheme; |
|
||||||
import com.fr.base.theme.TemplateTheme; |
|
||||||
import com.fr.base.theme.settings.ThemedComponentStyle; |
|
||||||
import com.fr.design.designer.IntervalConstants; |
|
||||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
|
||||||
import com.fr.design.designer.creator.PropertyGroupPane; |
|
||||||
import com.fr.design.designer.creator.XCreator; |
|
||||||
import com.fr.design.designer.creator.XElementCase; |
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.gui.style.FollowingThemePane; |
|
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
|
||||||
import com.fr.design.layout.TableLayoutHelper; |
|
||||||
import com.fr.design.mainframe.widget.accessibles.AccessibleElementCaseToolBarEditor; |
|
||||||
import com.fr.design.widget.ui.designer.component.PaddingBoundPane; |
|
||||||
import com.fr.design.widget.ui.designer.layout.WTitleLayoutDefinePane; |
|
||||||
import com.fr.form.main.Form; |
|
||||||
import com.fr.form.ui.ElementCaseEditor; |
|
||||||
import com.fr.form.ui.PaddingMargin; |
|
||||||
import com.fr.form.web.FormToolBarManager; |
|
||||||
import com.fr.general.ComparatorUtils; |
|
||||||
import com.fr.report.fit.ReportFitAttr; |
|
||||||
|
|
||||||
import javax.swing.BorderFactory; |
|
||||||
import javax.swing.JPanel; |
|
||||||
import java.awt.BorderLayout; |
|
||||||
import java.awt.Component; |
|
||||||
import java.util.ArrayList; |
|
||||||
import java.util.List; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by kerry on 2020-04-09 |
|
||||||
*/ |
|
||||||
public class ElementEditorExtendDefinePane extends WTitleLayoutDefinePane<ElementCaseEditor> { |
|
||||||
private final PaddingBoundPane paddingBoundPane; |
|
||||||
private AccessibleElementCaseToolBarEditor elementCaseToolBarEditor; |
|
||||||
private PropertyGroupPane extraPropertyGroupPane; |
|
||||||
private PcFitExpandablePane pcFitExpandablePane; |
|
||||||
|
|
||||||
private static final String FIT_STATE_PC = "fitStateInPC"; |
|
||||||
|
|
||||||
public ElementEditorExtendDefinePane(XCreator xCreator) { |
|
||||||
super(xCreator); |
|
||||||
paddingBoundPane = new PaddingBoundPane(); |
|
||||||
themePane.addFollowThemePane(paddingBoundPane, new FollowingThemePane.FollowingThemeActionChangeListener() { |
|
||||||
@Override |
|
||||||
public void onFollowingTheme(boolean following) { |
|
||||||
paddingBoundPane.setVisible(!following); |
|
||||||
|
|
||||||
if (following) { |
|
||||||
TemplateTheme theme = themePane.getUsingTheme(); |
|
||||||
if (theme instanceof FormTheme) { |
|
||||||
ThemedComponentStyle style = ((FormTheme) theme).getComponentStyle(); |
|
||||||
int top = style.getPaddingTop(); |
|
||||||
int bottom = style.getPaddingBottom(); |
|
||||||
int left = style.getPaddingLeft(); |
|
||||||
int right = style.getPaddingRight(); |
|
||||||
paddingBoundPane.populateBean(new PaddingMargin(top, left, bottom, right)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
protected JPanel createCenterPane() { |
|
||||||
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
elementCaseToolBarEditor = new AccessibleElementCaseToolBarEditor(); |
|
||||||
Component[][] components = new Component[][]{ |
|
||||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_EC_Toolbar")), elementCaseToolBarEditor}, |
|
||||||
}; |
|
||||||
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); |
|
||||||
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0)); |
|
||||||
CRPropertyDescriptor[] extraTableEditor = removeOldFitEditor(((XElementCase) creator).getExtraTableEditor()); |
|
||||||
extraPropertyGroupPane = new PropertyGroupPane(extraTableEditor, creator); |
|
||||||
centerPane.add(panel, BorderLayout.NORTH); |
|
||||||
if (extraTableEditor.length > 0) { |
|
||||||
centerPane.add(extraPropertyGroupPane, BorderLayout.CENTER); |
|
||||||
} |
|
||||||
pcFitExpandablePane = new PcFitExpandablePane(this); |
|
||||||
centerPane.add(pcFitExpandablePane, BorderLayout.SOUTH); |
|
||||||
return centerPane; |
|
||||||
} |
|
||||||
|
|
||||||
private CRPropertyDescriptor[] removeOldFitEditor(CRPropertyDescriptor[] extraTableEditor) { |
|
||||||
List<CRPropertyDescriptor> list = new ArrayList<CRPropertyDescriptor>(); |
|
||||||
for (CRPropertyDescriptor crPropertyDescriptor : extraTableEditor) { |
|
||||||
if (!ComparatorUtils.equals(FIT_STATE_PC, crPropertyDescriptor.getName())) { |
|
||||||
list.add(crPropertyDescriptor); |
|
||||||
} |
|
||||||
} |
|
||||||
return list.toArray(new CRPropertyDescriptor[list.size()]); |
|
||||||
} |
|
||||||
|
|
||||||
protected ElementCaseEditor updateSubBean() { |
|
||||||
ElementCaseEditor elementCaseEditor = (ElementCaseEditor) creator.toData(); |
|
||||||
if (themePane.isFollowingTheme() || ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) { |
|
||||||
paddingBoundPane.update(elementCaseEditor); |
|
||||||
} |
|
||||||
elementCaseEditor.setToolBars((FormToolBarManager[]) elementCaseToolBarEditor.getValue()); |
|
||||||
ReportFitAttr fitAttr = pcFitExpandablePane.update(); |
|
||||||
elementCaseEditor.setReportFitAttr(fitAttr); |
|
||||||
return elementCaseEditor; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
protected void populateSubBean(ElementCaseEditor ob) { |
|
||||||
paddingBoundPane.populate(ob); |
|
||||||
elementCaseToolBarEditor.setValue(ob.getToolBars()); |
|
||||||
extraPropertyGroupPane.populate(ob); |
|
||||||
pcFitExpandablePane.populate(ob.getReportFitAttr()); |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -1,200 +0,0 @@ |
|||||||
package com.fr.design.fit.attrpane; |
|
||||||
|
|
||||||
import com.fr.base.io.IOFile; |
|
||||||
import com.fr.base.iofile.attr.WatermarkAttr; |
|
||||||
import com.fr.base.theme.FormTheme; |
|
||||||
import com.fr.base.theme.TemplateTheme; |
|
||||||
import com.fr.design.data.DataCreatorUI; |
|
||||||
import com.fr.design.designer.IntervalConstants; |
|
||||||
import com.fr.design.designer.creator.XCreator; |
|
||||||
import com.fr.design.designer.creator.XWFitLayout; |
|
||||||
import com.fr.design.designer.properties.items.FRLayoutTypeItems; |
|
||||||
import com.fr.design.designer.properties.items.Item; |
|
||||||
import com.fr.design.foldablepane.UIExpandablePane; |
|
||||||
import com.fr.design.gui.icombobox.UIComboBox; |
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.gui.style.FollowingThemePane; |
|
||||||
import com.fr.design.gui.xpane.LayoutStylePane; |
|
||||||
import com.fr.design.i18n.Toolkit; |
|
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
|
||||||
import com.fr.design.layout.TableLayout; |
|
||||||
import com.fr.design.layout.TableLayoutHelper; |
|
||||||
import com.fr.design.mainframe.WidgetPropertyPane; |
|
||||||
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; |
|
||||||
import com.fr.design.utils.gui.UIComponentUtils; |
|
||||||
import com.fr.design.widget.FRWidgetFactory; |
|
||||||
import com.fr.design.widget.ui.designer.component.WidgetBoundPane; |
|
||||||
import com.fr.design.widget.ui.designer.layout.FRAbsoluteLayoutDefinePane; |
|
||||||
import com.fr.form.ui.LayoutBorderStyle; |
|
||||||
import com.fr.form.ui.container.WAbsoluteBodyLayout; |
|
||||||
import com.fr.form.ui.container.WAbsoluteLayout; |
|
||||||
import com.fr.form.ui.container.WBodyLayoutType; |
|
||||||
import com.fr.general.act.BorderPacker; |
|
||||||
import com.fr.report.core.ReportUtils; |
|
||||||
|
|
||||||
import javax.swing.BorderFactory; |
|
||||||
import javax.swing.DefaultComboBoxModel; |
|
||||||
import javax.swing.JPanel; |
|
||||||
import java.awt.BorderLayout; |
|
||||||
import java.awt.Component; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by kerry on 2020-04-22 |
|
||||||
*/ |
|
||||||
public class FRAbsoluteBodyLayoutExtendDefinePane extends FRAbsoluteLayoutDefinePane { |
|
||||||
private static final int MAX_LABEL_WIDTH = 80; |
|
||||||
|
|
||||||
protected FollowingThemePane themePane; |
|
||||||
private LayoutStylePane stylePane; |
|
||||||
private AccessibleBodyWatermarkEditor watermarkEditor; |
|
||||||
|
|
||||||
private UIComboBox layoutCombox; |
|
||||||
private WBodyLayoutType layoutType = WBodyLayoutType.ABSOLUTE; |
|
||||||
|
|
||||||
public FRAbsoluteBodyLayoutExtendDefinePane(XCreator xCreator) { |
|
||||||
super(xCreator); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public void initComponent() { |
|
||||||
initUIComboBox(); |
|
||||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
||||||
|
|
||||||
JPanel panel1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
this.add(panel1, BorderLayout.CENTER); |
|
||||||
|
|
||||||
UIExpandablePane scalePane = new UIExpandablePane( |
|
||||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Area_Scaling"), |
|
||||||
280, 20, |
|
||||||
createAreaScalePane() |
|
||||||
); |
|
||||||
panel1.add(scalePane, BorderLayout.NORTH); |
|
||||||
|
|
||||||
UIExpandablePane advancedPane = new UIExpandablePane( |
|
||||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), |
|
||||||
280, 20, |
|
||||||
this.createAdvancePane()); |
|
||||||
panel1.add(advancedPane, BorderLayout.CENTER); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public JPanel createAdvancePane() { |
|
||||||
JPanel advancedContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
|
|
||||||
themePane = new FollowingThemePane(Toolkit.i18nText("Fine-Design_Form_Body_Style_Setting")); |
|
||||||
stylePane = new LayoutStylePane(); |
|
||||||
themePane.addFollowThemePane(stylePane, new FollowingThemePane.FollowingThemeActionChangeListener() { |
|
||||||
@Override |
|
||||||
public void onFollowingTheme(boolean following) { |
|
||||||
stylePane.supportBodyStyle(!following); |
|
||||||
|
|
||||||
BorderPacker style = stylePane.updateBean(); |
|
||||||
if (following) { |
|
||||||
TemplateTheme theme = themePane.getUsingTheme(); |
|
||||||
if (theme instanceof FormTheme) { |
|
||||||
style = ((FormTheme) theme).getBodyStyle().merge(style); |
|
||||||
} |
|
||||||
} |
|
||||||
stylePane.populateBean((LayoutBorderStyle) style); |
|
||||||
} |
|
||||||
}); |
|
||||||
advancedContentPane.add(themePane, BorderLayout.NORTH); |
|
||||||
|
|
||||||
watermarkEditor = new AccessibleBodyWatermarkEditor(); |
|
||||||
JPanel watermarkPane = TableLayoutHelper.createGapTableLayoutPane( |
|
||||||
new Component[][]{ |
|
||||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor} |
|
||||||
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); |
|
||||||
watermarkPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); |
|
||||||
advancedContentPane.add(watermarkPane, BorderLayout.CENTER); |
|
||||||
|
|
||||||
return advancedContentPane; |
|
||||||
} |
|
||||||
|
|
||||||
public JPanel createAreaScalePane() { |
|
||||||
initLayoutComboBox(); |
|
||||||
|
|
||||||
UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")); |
|
||||||
UILabel scaleModeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode")); |
|
||||||
|
|
||||||
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane( |
|
||||||
new Component[][]{ |
|
||||||
{layoutTypeLabel, layoutCombox}, |
|
||||||
{scaleModeLabel, comboBox} |
|
||||||
}, |
|
||||||
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
|
||||||
|
|
||||||
contentPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); |
|
||||||
|
|
||||||
JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
containerPane.add(contentPane, BorderLayout.CENTER); |
|
||||||
containerPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); |
|
||||||
|
|
||||||
return containerPane; |
|
||||||
} |
|
||||||
|
|
||||||
public void initLayoutComboBox() { |
|
||||||
Item[] items = FRLayoutTypeItems.ITEMS; |
|
||||||
DefaultComboBoxModel model = new DefaultComboBoxModel(); |
|
||||||
for (Item item : items) { |
|
||||||
model.addElement(item); |
|
||||||
} |
|
||||||
layoutCombox = new UIComboBox(model); |
|
||||||
layoutCombox.setSelectedIndex(1); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String title4PopupWindow() { |
|
||||||
return "absoluteBodyLayout"; |
|
||||||
} |
|
||||||
|
|
||||||
public void populateSubPane(WAbsoluteLayout ob) { |
|
||||||
layoutCombox.setSelectedIndex(1); |
|
||||||
themePane.supportFollowingTheme(ob.supportThemed()); |
|
||||||
themePane.setFollowingTheme(ob.isBorderStyleFollowingTheme()); |
|
||||||
stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle()); |
|
||||||
watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile())); |
|
||||||
} |
|
||||||
|
|
||||||
public WAbsoluteBodyLayout updateSubPane() { |
|
||||||
WAbsoluteBodyLayout layout = (WAbsoluteBodyLayout) creator.toData(); |
|
||||||
Item item = (Item) layoutCombox.getSelectedItem(); |
|
||||||
Object value = item.getValue(); |
|
||||||
int state = 0; |
|
||||||
if (value instanceof Integer) { |
|
||||||
state = (Integer) value; |
|
||||||
} |
|
||||||
|
|
||||||
if (layoutType == WBodyLayoutType.ABSOLUTE) { |
|
||||||
((XWFitLayout) creator.getBackupParent()).toData().resetStyle(); |
|
||||||
if (state == WBodyLayoutType.FIT.getTypeValue()) { |
|
||||||
XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent()); |
|
||||||
xwFitLayout.switch2FitBodyLayout(creator); |
|
||||||
copyLayoutAttr(layout, xwFitLayout.toData()); |
|
||||||
} |
|
||||||
} |
|
||||||
layout.setBorderStyleFollowingTheme(themePane.isFollowingTheme()); |
|
||||||
layout.setBorderStyle(stylePane.updateBean()); |
|
||||||
updateWatermark(); |
|
||||||
return layout; |
|
||||||
} |
|
||||||
|
|
||||||
private void updateWatermark() { |
|
||||||
WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue(); |
|
||||||
if (watermark != null) { |
|
||||||
IOFile ioFile = getCurrentIOFile(); |
|
||||||
ioFile.addAttrMark(watermark); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private IOFile getCurrentIOFile() { |
|
||||||
return WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public DataCreatorUI dataUI() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
@ -1,27 +0,0 @@ |
|||||||
package com.fr.design.fit.attrpane; |
|
||||||
|
|
||||||
import com.fr.design.designer.creator.XCreator; |
|
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
|
||||||
import com.fr.design.widget.ui.designer.layout.AbstractFRLayoutDefinePane; |
|
||||||
import com.fr.form.ui.container.WAbsoluteLayout; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by kerry on 2020-04-22 |
|
||||||
*/ |
|
||||||
public class FRAbsoluteLayoutExtendDefinePane extends AbstractFRLayoutDefinePane<WAbsoluteLayout> { |
|
||||||
|
|
||||||
public FRAbsoluteLayoutExtendDefinePane(XCreator xCreator) { |
|
||||||
super(xCreator); |
|
||||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void populateBean(WAbsoluteLayout ob) { |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public WAbsoluteLayout updateBean() { |
|
||||||
WAbsoluteLayout wAbsoluteLayout = (WAbsoluteLayout) creator.toData(); |
|
||||||
return wAbsoluteLayout; |
|
||||||
} |
|
||||||
} |
|
@ -1,282 +0,0 @@ |
|||||||
package com.fr.design.fit.attrpane; |
|
||||||
|
|
||||||
|
|
||||||
import com.fr.base.io.IOFile; |
|
||||||
import com.fr.base.iofile.attr.WatermarkAttr; |
|
||||||
import com.fr.base.theme.FormTheme; |
|
||||||
import com.fr.base.theme.TemplateTheme; |
|
||||||
import com.fr.design.data.DataCreatorUI; |
|
||||||
import com.fr.design.designer.IntervalConstants; |
|
||||||
import com.fr.design.designer.creator.XCreator; |
|
||||||
import com.fr.design.designer.creator.XLayoutContainer; |
|
||||||
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; |
|
||||||
import com.fr.design.designer.creator.XWFitLayout; |
|
||||||
import com.fr.design.designer.creator.XWScaleLayout; |
|
||||||
import com.fr.design.designer.properties.items.FRLayoutTypeItems; |
|
||||||
import com.fr.design.designer.properties.items.Item; |
|
||||||
import com.fr.design.foldablepane.UIExpandablePane; |
|
||||||
import com.fr.design.gui.icombobox.UIComboBox; |
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.gui.ispinner.UISpinner; |
|
||||||
import com.fr.design.gui.style.FollowingThemePane; |
|
||||||
import com.fr.design.gui.xpane.LayoutStylePane; |
|
||||||
import com.fr.design.i18n.Toolkit; |
|
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
|
||||||
import com.fr.design.layout.TableLayoutHelper; |
|
||||||
import com.fr.design.mainframe.FormDesigner; |
|
||||||
import com.fr.design.mainframe.FormSelectionUtils; |
|
||||||
import com.fr.design.mainframe.WidgetPropertyPane; |
|
||||||
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; |
|
||||||
import com.fr.design.utils.gui.UIComponentUtils; |
|
||||||
import com.fr.design.widget.FRWidgetFactory; |
|
||||||
import com.fr.design.widget.ui.designer.component.PaddingBoundPane; |
|
||||||
import com.fr.design.widget.ui.designer.layout.AbstractFRLayoutDefinePane; |
|
||||||
import com.fr.form.ui.LayoutBorderStyle; |
|
||||||
import com.fr.form.ui.Widget; |
|
||||||
import com.fr.form.ui.container.WAbsoluteBodyLayout; |
|
||||||
import com.fr.form.ui.container.WAbsoluteLayout; |
|
||||||
import com.fr.form.ui.container.WBodyLayoutType; |
|
||||||
import com.fr.form.ui.container.WFitLayout; |
|
||||||
import com.fr.general.ComparatorUtils; |
|
||||||
import com.fr.general.act.BorderPacker; |
|
||||||
import com.fr.log.FineLoggerFactory; |
|
||||||
import com.fr.report.core.ReportUtils; |
|
||||||
|
|
||||||
import javax.swing.BorderFactory; |
|
||||||
import javax.swing.DefaultComboBoxModel; |
|
||||||
import javax.swing.JPanel; |
|
||||||
import java.awt.BorderLayout; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Dimension; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by kerry on 2020-04-22 |
|
||||||
*/ |
|
||||||
public class FRFitLayoutExtendDefinePane extends AbstractFRLayoutDefinePane<WFitLayout> { |
|
||||||
private static final int ADAPT_LABEL_MAX_WIDTH = 80; |
|
||||||
private XWFitLayout xWFitLayout; |
|
||||||
private WFitLayout wFitLayout; |
|
||||||
private UIComboBox layoutComboBox; |
|
||||||
private UISpinner componentIntervel; |
|
||||||
private PaddingBoundPane paddingBound; |
|
||||||
private FollowingThemePane themePane; |
|
||||||
private LayoutStylePane stylePane; |
|
||||||
private AccessibleBodyWatermarkEditor watermarkEditor; |
|
||||||
|
|
||||||
public FRFitLayoutExtendDefinePane(XCreator xCreator) { |
|
||||||
super(xCreator); |
|
||||||
this.xWFitLayout = (XWFitLayout) xCreator; |
|
||||||
wFitLayout = xWFitLayout.toData(); |
|
||||||
initComponent(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public void initComponent() { |
|
||||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
||||||
UIExpandablePane layoutExpandablePane = new UIExpandablePane( |
|
||||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"), |
|
||||||
280, 20, |
|
||||||
createLayoutPane() |
|
||||||
); |
|
||||||
this.add(layoutExpandablePane, BorderLayout.NORTH); |
|
||||||
|
|
||||||
JPanel advancePane = createAdvancePane(); |
|
||||||
UIExpandablePane advanceExpandablePane = new UIExpandablePane( |
|
||||||
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), |
|
||||||
280, 20, |
|
||||||
advancePane |
|
||||||
); |
|
||||||
this.add(advanceExpandablePane, BorderLayout.CENTER); |
|
||||||
} |
|
||||||
|
|
||||||
public JPanel createAdvancePane() { |
|
||||||
JPanel contentPane0 = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
|
|
||||||
themePane = new FollowingThemePane(Toolkit.i18nText("Fine-Design_Form_Body_Style_Setting")); |
|
||||||
stylePane = new LayoutStylePane(); |
|
||||||
themePane.addFollowThemePane(stylePane, new FollowingThemePane.FollowingThemeActionChangeListener() { |
|
||||||
@Override |
|
||||||
public void onFollowingTheme(boolean following) { |
|
||||||
stylePane.supportBodyStyle(!following); |
|
||||||
|
|
||||||
BorderPacker style = stylePane.updateBean(); |
|
||||||
if (following) { |
|
||||||
TemplateTheme theme = themePane.getUsingTheme(); |
|
||||||
if (theme instanceof FormTheme) { |
|
||||||
style = ((FormTheme) theme).getBodyStyle().merge(style); |
|
||||||
} |
|
||||||
} |
|
||||||
stylePane.populateBean((LayoutBorderStyle) style); |
|
||||||
} |
|
||||||
}); |
|
||||||
contentPane0.add(themePane, BorderLayout.NORTH); |
|
||||||
|
|
||||||
JPanel contentPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
contentPane0.add(contentPane1, BorderLayout.CENTER); |
|
||||||
|
|
||||||
watermarkEditor = new AccessibleBodyWatermarkEditor(); |
|
||||||
JPanel waterMarkPane = TableLayoutHelper.createGapTableLayoutPane( |
|
||||||
new Component[][]{ |
|
||||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor} |
|
||||||
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); |
|
||||||
waterMarkPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
|
||||||
contentPane1.add(waterMarkPane, BorderLayout.NORTH); |
|
||||||
|
|
||||||
paddingBound = new PaddingBoundPane(); |
|
||||||
contentPane1.add(paddingBound, BorderLayout.CENTER); |
|
||||||
|
|
||||||
return contentPane0; |
|
||||||
} |
|
||||||
|
|
||||||
public JPanel createLayoutPane() { |
|
||||||
JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
|
|
||||||
layoutComboBox = initUIComboBox(FRLayoutTypeItems.ITEMS); |
|
||||||
componentIntervel = new UISpinner(0, Integer.MAX_VALUE, 1, 0); |
|
||||||
JPanel componentIntervelPane = UIComponentUtils.wrapWithBorderLayoutPane(componentIntervel); |
|
||||||
|
|
||||||
UILabel intervalLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Interval")); |
|
||||||
|
|
||||||
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane( |
|
||||||
new Component[][]{ |
|
||||||
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox}, |
|
||||||
{intervalLabel, componentIntervelPane} |
|
||||||
}, |
|
||||||
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
|
||||||
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); |
|
||||||
containerPane.add(contentPane, BorderLayout.CENTER); |
|
||||||
|
|
||||||
return containerPane; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public UIComboBox initUIComboBox(Item[] items) { |
|
||||||
DefaultComboBoxModel model = new DefaultComboBoxModel(); |
|
||||||
for (Item item : items) { |
|
||||||
model.addElement(item); |
|
||||||
} |
|
||||||
return new UIComboBox(model); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public String title4PopupWindow() { |
|
||||||
return "fitLayout"; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void populateBean(WFitLayout ob) { |
|
||||||
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
|
||||||
XLayoutContainer rootLayout = selectedBodyLayout(formDesigner); |
|
||||||
if (rootLayout != formDesigner.getRootComponent() |
|
||||||
&& formDesigner.getSelectionModel().getSelection().getSelectedCreator() == formDesigner.getRootComponent()) { |
|
||||||
formDesigner.getSelectionModel().setSelectedCreators( |
|
||||||
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{selectedBodyLayout(formDesigner).toData()})); |
|
||||||
|
|
||||||
} |
|
||||||
paddingBound.populate(ob); |
|
||||||
layoutComboBox.setSelectedIndex(ob.getBodyLayoutType().getTypeValue()); |
|
||||||
componentIntervel.setValue(ob.getCompInterval()); |
|
||||||
themePane.supportFollowingTheme(ob.supportThemed()); |
|
||||||
themePane.setFollowingTheme(ob.isBorderStyleFollowingTheme()); |
|
||||||
stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle()); |
|
||||||
watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile())); |
|
||||||
} |
|
||||||
|
|
||||||
private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) { |
|
||||||
XLayoutContainer rootLayout = formDesigner.getRootComponent(); |
|
||||||
if (rootLayout.getComponentCount() == 1 && rootLayout.getXCreator(0).acceptType(XWAbsoluteBodyLayout.class)) { |
|
||||||
rootLayout = (XWAbsoluteBodyLayout) rootLayout.getXCreator(0); |
|
||||||
} |
|
||||||
return rootLayout; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public WFitLayout updateBean() { |
|
||||||
WFitLayout layout = (WFitLayout) creator.toData(); |
|
||||||
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) { |
|
||||||
paddingBound.update(layout); |
|
||||||
} |
|
||||||
layout.setBorderStyleFollowingTheme(themePane.isFollowingTheme()); |
|
||||||
LayoutBorderStyle borderStyle = stylePane.updateBean(); |
|
||||||
if (borderStyle != null) { |
|
||||||
layout.setBorderStyle(borderStyle); |
|
||||||
} |
|
||||||
updateWatermark(); |
|
||||||
Item item = (Item) layoutComboBox.getSelectedItem(); |
|
||||||
Object value = item.getValue(); |
|
||||||
int state = 0; |
|
||||||
if (value instanceof Integer) { |
|
||||||
state = (Integer) value; |
|
||||||
} |
|
||||||
//todo 验证下
|
|
||||||
layout.setLayoutType(WBodyLayoutType.parse(state)); |
|
||||||
try { |
|
||||||
if (state == WBodyLayoutType.ABSOLUTE.getTypeValue()) { |
|
||||||
WAbsoluteBodyLayout wAbsoluteBodyLayout = new WAbsoluteBodyLayout("body"); |
|
||||||
wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED); |
|
||||||
Component[] components = xWFitLayout.getComponents(); |
|
||||||
xWFitLayout.removeAll(); |
|
||||||
layout.resetStyle(); |
|
||||||
XWAbsoluteBodyLayout xwAbsoluteBodyLayout = xWFitLayout.getBackupParent() == null ? new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0)) : (XWAbsoluteBodyLayout) xWFitLayout.getBackupParent(); |
|
||||||
xWFitLayout.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0); |
|
||||||
for (Component component : components) { |
|
||||||
XCreator xCreator = (XCreator) component; |
|
||||||
//部分控件被ScaleLayout包裹着,绝对布局里面要放出来
|
|
||||||
if (xCreator.acceptType(XWScaleLayout.class)) { |
|
||||||
if (xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator()) { |
|
||||||
component = xCreator.getComponent(0); |
|
||||||
component.setBounds(xCreator.getBounds()); |
|
||||||
} |
|
||||||
} |
|
||||||
xwAbsoluteBodyLayout.add(component); |
|
||||||
} |
|
||||||
copyLayoutAttr(wFitLayout, wAbsoluteBodyLayout); |
|
||||||
xWFitLayout.setBackupParent(xwAbsoluteBodyLayout); |
|
||||||
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
|
||||||
formDesigner.getSelectionModel().setSelectedCreators( |
|
||||||
FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); |
|
||||||
} |
|
||||||
} catch (Exception e) { |
|
||||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
int intervelValue = (int) componentIntervel.getValue(); |
|
||||||
if (xWFitLayout.canAddInterval(intervelValue)) { |
|
||||||
// 设置完间隔后,要同步处理界面组件,容器刷新后显示出对应效果
|
|
||||||
setLayoutGap(intervelValue); |
|
||||||
} |
|
||||||
|
|
||||||
return layout; |
|
||||||
} |
|
||||||
|
|
||||||
private void updateWatermark() { |
|
||||||
WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue(); |
|
||||||
if (watermark != null) { |
|
||||||
IOFile ioFile = getCurrentIOFile(); |
|
||||||
ioFile.addAttrMark(watermark); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private IOFile getCurrentIOFile() { |
|
||||||
return WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget(); |
|
||||||
} |
|
||||||
|
|
||||||
private void setLayoutGap(int value) { |
|
||||||
int interval = wFitLayout.getCompInterval(); |
|
||||||
if (value != interval) { |
|
||||||
xWFitLayout.moveContainerMargin(); |
|
||||||
xWFitLayout.moveCompInterval(xWFitLayout.getAcualInterval()); |
|
||||||
wFitLayout.setCompInterval(value); |
|
||||||
xWFitLayout.addCompInterval(xWFitLayout.getAcualInterval()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public DataCreatorUI dataUI() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,303 +0,0 @@ |
|||||||
package com.fr.design.fit.attrpane; |
|
||||||
|
|
||||||
import com.fr.base.BaseUtils; |
|
||||||
import com.fr.design.ExtraDesignClassManager; |
|
||||||
import com.fr.design.data.DataCreatorUI; |
|
||||||
import com.fr.design.designer.IntervalConstants; |
|
||||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
|
||||||
import com.fr.design.designer.creator.PropertyGroupPane; |
|
||||||
import com.fr.design.designer.creator.XCreator; |
|
||||||
import com.fr.design.designer.creator.XWParameterLayout; |
|
||||||
import com.fr.design.designer.properties.PropertyTab; |
|
||||||
import com.fr.design.file.HistoryTemplateListPane; |
|
||||||
import com.fr.design.fit.DesignerUIModeConfig; |
|
||||||
import com.fr.design.fit.common.TemplateTool; |
|
||||||
import com.fr.design.foldablepane.UIExpandablePane; |
|
||||||
import com.fr.design.fun.ParameterExpandablePaneUIProvider; |
|
||||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
|
||||||
import com.fr.design.gui.icheckbox.UICheckBox; |
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.gui.ispinner.UISpinner; |
|
||||||
import com.fr.design.gui.itextfield.UITextField; |
|
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
|
||||||
import com.fr.design.layout.TableLayout; |
|
||||||
import com.fr.design.layout.TableLayoutHelper; |
|
||||||
import com.fr.design.mainframe.FormDesigner; |
|
||||||
import com.fr.design.mainframe.FormSelection; |
|
||||||
import com.fr.design.mainframe.JTemplate; |
|
||||||
import com.fr.design.mainframe.widget.accessibles.AccessibleBackgroundEditor; |
|
||||||
import com.fr.design.utils.gui.LayoutUtils; |
|
||||||
import com.fr.design.utils.gui.UIComponentUtils; |
|
||||||
import com.fr.design.widget.ui.designer.AbstractDataModify; |
|
||||||
import com.fr.design.widget.ui.designer.component.UIBoundSpinner; |
|
||||||
import com.fr.form.ui.container.WParameterLayout; |
|
||||||
import com.fr.general.Background; |
|
||||||
import com.fr.report.stable.FormConstants; |
|
||||||
|
|
||||||
import javax.swing.BorderFactory; |
|
||||||
import javax.swing.Icon; |
|
||||||
import javax.swing.JPanel; |
|
||||||
import java.awt.BorderLayout; |
|
||||||
import java.awt.Component; |
|
||||||
import java.awt.Rectangle; |
|
||||||
import java.util.Set; |
|
||||||
|
|
||||||
public class RootDesignExtendDefinePane extends AbstractDataModify<WParameterLayout> { |
|
||||||
private XWParameterLayout root; |
|
||||||
private UISpinner designerWidth; |
|
||||||
private UISpinner paraHeight; |
|
||||||
private UICheckBox displayReport; |
|
||||||
private UICheckBox useParamsTemplate; |
|
||||||
private AccessibleBackgroundEditor background; |
|
||||||
private UIButtonGroup hAlignmentPane; |
|
||||||
private UITextField labelNameTextField; |
|
||||||
//是否是新设计模式下决策报表
|
|
||||||
private boolean newForm; |
|
||||||
private PropertyGroupPane extraPropertyGroupPane; |
|
||||||
|
|
||||||
public RootDesignExtendDefinePane(XCreator xCreator) { |
|
||||||
super(xCreator); |
|
||||||
newForm = TemplateTool.getCurrentEditingNewJForm() != null && DesignerUIModeConfig.getInstance().newUIMode(); |
|
||||||
this.root = (XWParameterLayout) xCreator; |
|
||||||
initComponent(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public void initComponent() { |
|
||||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
||||||
if (newForm) { |
|
||||||
paraHeight = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0); |
|
||||||
} else { |
|
||||||
designerWidth = new UIBoundSpinner(1, Integer.MAX_VALUE, 1); |
|
||||||
} |
|
||||||
JPanel advancePane = createAdvancePane(); |
|
||||||
UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane); |
|
||||||
this.add(advanceExpandablePane, BorderLayout.NORTH); |
|
||||||
JPanel layoutPane = createBoundsPane(); |
|
||||||
UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Size"), 280, 20, layoutPane); |
|
||||||
this.add(layoutExpandablePane, BorderLayout.CENTER); |
|
||||||
this.addExtraUIExpandablePaneFromPlugin(); |
|
||||||
} |
|
||||||
|
|
||||||
private void addExtraUIExpandablePaneFromPlugin() { |
|
||||||
Set<ParameterExpandablePaneUIProvider> pluginCreators = ExtraDesignClassManager.getInstance().getArray(ParameterExpandablePaneUIProvider.XML_TAG); |
|
||||||
JPanel panel = FRGUIPaneFactory.createYBoxEmptyBorderPane(); |
|
||||||
for (ParameterExpandablePaneUIProvider provider : pluginCreators) { |
|
||||||
UIExpandablePane uiExpandablePane = provider.createUIExpandablePane(); |
|
||||||
PropertyTab propertyTab = provider.addToWhichPropertyTab(); |
|
||||||
if (uiExpandablePane != null && propertyTab == PropertyTab.ATTR) { |
|
||||||
panel.add(uiExpandablePane); |
|
||||||
} |
|
||||||
} |
|
||||||
this.add(panel, BorderLayout.SOUTH); |
|
||||||
} |
|
||||||
|
|
||||||
public JPanel createBoundsPane() { |
|
||||||
double f = TableLayout.FILL; |
|
||||||
double p = TableLayout.PREFERRED; |
|
||||||
double[] rowSize = {p}; |
|
||||||
double[] columnSize = {p, f}; |
|
||||||
int[][] rowCount = {{1, 1}}; |
|
||||||
Component[] component = newForm ? new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit_Design_Height")), paraHeight} : |
|
||||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Desin_Width")), designerWidth}; |
|
||||||
Component[][] components = new Component[][]{component}; |
|
||||||
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
|
||||||
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); |
|
||||||
jPanel.add(panel); |
|
||||||
return jPanel; |
|
||||||
} |
|
||||||
|
|
||||||
public JPanel createAdvancePane() { |
|
||||||
if (newForm) { |
|
||||||
return getNewFormAdvancePane(); |
|
||||||
} else { |
|
||||||
return getTemplateAdvancePane(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @Description: 获取的非新决策报表AdvancePane |
|
||||||
* @param |
|
||||||
* @return: |
|
||||||
* @Author: Henry.Wang |
|
||||||
* @date: 2020/11/05 15:36 |
|
||||||
*/ |
|
||||||
private JPanel getTemplateAdvancePane() { |
|
||||||
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
labelNameTextField = new UITextField(); |
|
||||||
displayReport = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Display_Nothing_Before_Query")); |
|
||||||
UIComponentUtils.setLineWrap(displayReport); |
|
||||||
useParamsTemplate = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Use_Params_Template")); |
|
||||||
background = new AccessibleBackgroundEditor(); |
|
||||||
Icon[] hAlignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), |
|
||||||
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), |
|
||||||
BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"),}; |
|
||||||
Integer[] hAlignment = new Integer[]{FormConstants.LEFTPOSITION, FormConstants.CENTERPOSITION, FormConstants.RIGHTPOSITION}; |
|
||||||
hAlignmentPane = new UIButtonGroup<Integer>(hAlignmentIconArray, hAlignment); |
|
||||||
hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Left") |
|
||||||
, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right")}); |
|
||||||
double f = TableLayout.FILL; |
|
||||||
double p = TableLayout.PREFERRED; |
|
||||||
double[] rowSize = {p, p, p, p, p}; |
|
||||||
double[] columnSize = {p, f}; |
|
||||||
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; |
|
||||||
Component[][] components = new Component[][]{ |
|
||||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField}, |
|
||||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), background}, |
|
||||||
new Component[]{displayReport, null}, |
|
||||||
new Component[]{useParamsTemplate, null}, |
|
||||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Display_Position")), hAlignmentPane} |
|
||||||
}; |
|
||||||
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); |
|
||||||
panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); |
|
||||||
CRPropertyDescriptor[] extraTableEditor = new CRPropertyDescriptor[0]; |
|
||||||
extraTableEditor = root.getExtraTableEditor(); |
|
||||||
extraPropertyGroupPane = new PropertyGroupPane(extraTableEditor, root); |
|
||||||
|
|
||||||
jPanel.add(panel, BorderLayout.NORTH); |
|
||||||
jPanel.add(extraPropertyGroupPane, BorderLayout.CENTER); |
|
||||||
return jPanel; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @Description: 获取新决策报表的AdvancePane |
|
||||||
* @param |
|
||||||
* @return: |
|
||||||
* @Author: Henry.Wang |
|
||||||
* @date: 2020/11/05 15:36 |
|
||||||
*/ |
|
||||||
private JPanel getNewFormAdvancePane() { |
|
||||||
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
labelNameTextField = new UITextField(); |
|
||||||
displayReport = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Display_Nothing_Before_Query")); |
|
||||||
UIComponentUtils.setLineWrap(displayReport); |
|
||||||
useParamsTemplate = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Use_Params_Template")); |
|
||||||
background = new AccessibleBackgroundEditor(); |
|
||||||
|
|
||||||
double f = TableLayout.FILL; |
|
||||||
double p = TableLayout.PREFERRED; |
|
||||||
double[] rowSize = {p, p, p, p}; |
|
||||||
double[] columnSize = {p, f}; |
|
||||||
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}}; |
|
||||||
Component[][] components = new Component[][]{ |
|
||||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField}, |
|
||||||
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), background}, |
|
||||||
new Component[]{displayReport, null}, |
|
||||||
new Component[]{useParamsTemplate, null} |
|
||||||
}; |
|
||||||
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); |
|
||||||
panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0)); |
|
||||||
|
|
||||||
jPanel.add(panel, BorderLayout.NORTH); |
|
||||||
|
|
||||||
return jPanel; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String title4PopupWindow() { |
|
||||||
return "parameter"; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void populateBean(WParameterLayout ob) { |
|
||||||
labelNameTextField.setText(ob.getLabelName()); |
|
||||||
background.setValue(ob.getBackground()); |
|
||||||
displayReport.setSelected(ob.isDelayDisplayContent()); |
|
||||||
useParamsTemplate.setSelected(ob.isUseParamsTemplate()); |
|
||||||
if (newForm) { |
|
||||||
FormDesigner designer = TemplateTool.getCurrentEditingNewJForm().getFormDesign(); |
|
||||||
paraHeight.setValue(designer.getParaHeight()); |
|
||||||
} else { |
|
||||||
designerWidth.setValue(ob.getDesignWidth()); |
|
||||||
hAlignmentPane.setSelectedItem(ob.getPosition()); |
|
||||||
|
|
||||||
if (extraPropertyGroupPane != null) { |
|
||||||
extraPropertyGroupPane.populate(ob); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public WParameterLayout updateBean() { |
|
||||||
if (newForm) { |
|
||||||
return updateNewFormBean(); |
|
||||||
} else { |
|
||||||
return updateTemplateBean(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @Description: 更新非新决策报表的bean |
|
||||||
* @param |
|
||||||
* @return: |
|
||||||
* @Author: Henry.Wang |
|
||||||
* @date: 2020/11/05 15:36 |
|
||||||
*/ |
|
||||||
private WParameterLayout updateTemplateBean() { |
|
||||||
WParameterLayout wParameterLayout = (WParameterLayout) creator.toData(); |
|
||||||
wParameterLayout.setLabelName(labelNameTextField.getText()); |
|
||||||
if (isCompsOutOfDesignerWidth((int) designerWidth.getValue())) { |
|
||||||
designerWidth.setValue(wParameterLayout.getDesignWidth()); |
|
||||||
} else { |
|
||||||
wParameterLayout.setDesignWidth((int) designerWidth.getValue()); |
|
||||||
} |
|
||||||
wParameterLayout.setDelayDisplayContent(displayReport.isSelected()); |
|
||||||
wParameterLayout.setUseParamsTemplate(useParamsTemplate.isSelected()); |
|
||||||
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
||||||
jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected()); |
|
||||||
wParameterLayout.setBackground((Background) background.getValue()); |
|
||||||
wParameterLayout.setPosition((Integer) hAlignmentPane.getSelectedItem()); |
|
||||||
return wParameterLayout; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* @Description: 更新新决策报表的bean |
|
||||||
* @param |
|
||||||
* @return: |
|
||||||
* @Author: Henry.Wang |
|
||||||
* @date: 2020/11/05 15:36 |
|
||||||
*/ |
|
||||||
private WParameterLayout updateNewFormBean() { |
|
||||||
WParameterLayout wParameterLayout = (WParameterLayout) creator.toData(); |
|
||||||
wParameterLayout.setLabelName(labelNameTextField.getText()); |
|
||||||
|
|
||||||
wParameterLayout.setDelayDisplayContent(displayReport.isSelected()); |
|
||||||
wParameterLayout.setUseParamsTemplate(useParamsTemplate.isSelected()); |
|
||||||
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
|
||||||
jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected()); |
|
||||||
wParameterLayout.setBackground((Background) background.getValue()); |
|
||||||
//设置参数模板面板的高度
|
|
||||||
int height = (int) paraHeight.getTextField().getValue(); |
|
||||||
FormDesigner designer = TemplateTool.getCurrentEditingNewJForm().getFormDesign(); |
|
||||||
FormSelection selection = designer.getSelectionModel().getSelection(); |
|
||||||
XCreator creator = designer.getParaComponent(); |
|
||||||
Rectangle rectangle = creator.getBounds(); |
|
||||||
Rectangle newRectangle = new Rectangle(rectangle.x, rectangle.y, rectangle.width, height); |
|
||||||
creator.setBounds(newRectangle); |
|
||||||
if (paraHeight.getValue() != newRectangle.height) |
|
||||||
paraHeight.setValue(newRectangle.height); |
|
||||||
designer.setParaHeight(newRectangle.height); |
|
||||||
designer.getArea().doLayout(); |
|
||||||
LayoutUtils.layoutContainer(creator); |
|
||||||
selection.fixCreator(designer); |
|
||||||
designer.repaint(); |
|
||||||
return wParameterLayout; |
|
||||||
} |
|
||||||
|
|
||||||
private boolean isCompsOutOfDesignerWidth(int designerWidth) { |
|
||||||
for (int i = 0; i < root.getComponentCount(); i++) { |
|
||||||
Component comp = root.getComponent(i); |
|
||||||
if (comp.getX() + comp.getWidth() > designerWidth) { |
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public DataCreatorUI dataUI() { |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,31 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import java.awt.event.MouseWheelEvent; |
||||||
|
import java.awt.event.MouseWheelListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/9/23 |
||||||
|
*/ |
||||||
|
public class DesignerScaleMouseWheelHandler implements MouseWheelListener { |
||||||
|
private final ScalePane scalePane; |
||||||
|
private final int step; |
||||||
|
|
||||||
|
public DesignerScaleMouseWheelHandler(ScalePane scalePane, int step) { |
||||||
|
this.scalePane = scalePane; |
||||||
|
this.step = step; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseWheelMoved(MouseWheelEvent e) { |
||||||
|
int dir = e.getWheelRotation(); |
||||||
|
JFormSliderPane slidePane = this.scalePane.getSlidePane(); |
||||||
|
int old_resolution = slidePane.getShowValue(); |
||||||
|
slidePane.setShowValue(old_resolution - (dir * step)); |
||||||
|
} |
||||||
|
|
||||||
|
public interface ScalePane { |
||||||
|
JFormSliderPane getSlidePane(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,279 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import javax.swing.JScrollBar; |
||||||
|
import javax.swing.JViewport; |
||||||
|
import javax.swing.Scrollable; |
||||||
|
import javax.swing.SwingConstants; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Rectangle; |
||||||
|
import java.awt.event.MouseWheelEvent; |
||||||
|
import java.awt.event.MouseWheelListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* 实现设计器面板的触摸板滚动移动交互 https://work.fineres.com/browse/REPORT-55989
|
||||||
|
* |
||||||
|
* mouseWheelMoved 的具体实现来自 |
||||||
|
* @link {javax.swing.plaf.basic.BasicScrollPaneUI.Handler#mouseWheelMoved} |
||||||
|
* scrollByUnits 的具体实现来自 |
||||||
|
* @link {javax.swing.plaf.basic.BasicScrollPaneUI#scrollByUnits} |
||||||
|
* scrollByBlock 的具体实现来自 |
||||||
|
* @link {javax.swing.plaf.basic.BasicScrollPaneUI#scrollByBlock} |
||||||
|
*/ |
||||||
|
public class DesignerTranslateMouseWheelHandler implements MouseWheelListener { |
||||||
|
private final ScrollPane scrollpane; |
||||||
|
|
||||||
|
public DesignerTranslateMouseWheelHandler(ScrollPane scrollpane) { |
||||||
|
this.scrollpane = scrollpane; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseWheelMoved(MouseWheelEvent e) { |
||||||
|
if (scrollpane.isWheelScrollingEnabled() && |
||||||
|
e.getWheelRotation() != 0) { |
||||||
|
JScrollBar toScroll = scrollpane.getVerticalScrollBar(); |
||||||
|
int direction = e.getWheelRotation() < 0 ? -1 : 1; |
||||||
|
int orientation = SwingConstants.VERTICAL; |
||||||
|
|
||||||
|
// find which scrollbar to scroll, or return if none
|
||||||
|
if (toScroll == null || !toScroll.isVisible() |
||||||
|
|| e.isShiftDown()) { |
||||||
|
toScroll = scrollpane.getHorizontalScrollBar(); |
||||||
|
if (toScroll == null || !toScroll.isVisible()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
orientation = SwingConstants.HORIZONTAL; |
||||||
|
} |
||||||
|
|
||||||
|
e.consume(); |
||||||
|
|
||||||
|
if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { |
||||||
|
JViewport vp = scrollpane.getViewport(); |
||||||
|
if (vp == null) { return; } |
||||||
|
Component comp = vp.getView(); |
||||||
|
int units = Math.abs(e.getUnitsToScroll()); |
||||||
|
|
||||||
|
// When the scrolling speed is set to maximum, it's possible
|
||||||
|
// for a single wheel click to scroll by more units than
|
||||||
|
// will fit in the visible area. This makes it
|
||||||
|
// hard/impossible to get to certain parts of the scrolling
|
||||||
|
// Component with the wheel. To make for more accurate
|
||||||
|
// low-speed scrolling, we limit scrolling to the block
|
||||||
|
// increment if the wheel was only rotated one click.
|
||||||
|
boolean limitScroll = Math.abs(e.getWheelRotation()) == 1; |
||||||
|
|
||||||
|
// Check if we should use the visibleRect trick
|
||||||
|
Object fastWheelScroll = toScroll.getClientProperty( |
||||||
|
"JScrollBar.fastWheelScrolling"); |
||||||
|
if (Boolean.TRUE == fastWheelScroll && |
||||||
|
comp instanceof Scrollable) { |
||||||
|
// 5078454: Under maximum acceleration, we may scroll
|
||||||
|
// by many 100s of units in ~1 second.
|
||||||
|
//
|
||||||
|
// BasicScrollBarUI.scrollByUnits() can bog down the EDT
|
||||||
|
// with repaints in this situation. However, the
|
||||||
|
// Scrollable interface allows us to pass in an
|
||||||
|
// arbitrary visibleRect. This allows us to accurately
|
||||||
|
// calculate the total scroll amount, and then update
|
||||||
|
// the GUI once. This technique provides much faster
|
||||||
|
// accelerated wheel scrolling.
|
||||||
|
Scrollable scrollComp = (Scrollable) comp; |
||||||
|
Rectangle viewRect = vp.getViewRect(); |
||||||
|
int startingX = viewRect.x; |
||||||
|
boolean leftToRight = |
||||||
|
comp.getComponentOrientation().isLeftToRight(); |
||||||
|
int scrollMin = toScroll.getMinimum(); |
||||||
|
int scrollMax = toScroll.getMaximum() - |
||||||
|
toScroll.getModel().getExtent(); |
||||||
|
|
||||||
|
if (limitScroll) { |
||||||
|
int blockIncr = |
||||||
|
scrollComp.getScrollableBlockIncrement(viewRect, |
||||||
|
orientation, |
||||||
|
direction); |
||||||
|
if (direction < 0) { |
||||||
|
scrollMin = Math.max(scrollMin, |
||||||
|
toScroll.getValue() - blockIncr); |
||||||
|
} |
||||||
|
else { |
||||||
|
scrollMax = Math.min(scrollMax, |
||||||
|
toScroll.getValue() + blockIncr); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
for (int i = 0; i < units; i++) { |
||||||
|
int unitIncr = |
||||||
|
scrollComp.getScrollableUnitIncrement(viewRect, |
||||||
|
orientation, direction); |
||||||
|
// Modify the visible rect for the next unit, and
|
||||||
|
// check to see if we're at the end already.
|
||||||
|
if (orientation == SwingConstants.VERTICAL) { |
||||||
|
if (direction < 0) { |
||||||
|
viewRect.y -= unitIncr; |
||||||
|
if (viewRect.y <= scrollMin) { |
||||||
|
viewRect.y = scrollMin; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
else { // (direction > 0
|
||||||
|
viewRect.y += unitIncr; |
||||||
|
if (viewRect.y >= scrollMax) { |
||||||
|
viewRect.y = scrollMax; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
// Scroll left
|
||||||
|
if ((leftToRight && direction < 0) || |
||||||
|
(!leftToRight && direction > 0)) { |
||||||
|
viewRect.x -= unitIncr; |
||||||
|
if (leftToRight) { |
||||||
|
if (viewRect.x < scrollMin) { |
||||||
|
viewRect.x = scrollMin; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
// Scroll right
|
||||||
|
else if ((leftToRight && direction > 0) || |
||||||
|
(!leftToRight && direction < 0)) { |
||||||
|
viewRect.x += unitIncr; |
||||||
|
if (leftToRight) { |
||||||
|
if (viewRect.x > scrollMax) { |
||||||
|
viewRect.x = scrollMax; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
assert false : "Non-sensical ComponentOrientation / scroll direction"; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
// Set the final view position on the ScrollBar
|
||||||
|
if (orientation == SwingConstants.VERTICAL) { |
||||||
|
toScroll.setValue(viewRect.y); |
||||||
|
} |
||||||
|
else { |
||||||
|
if (leftToRight) { |
||||||
|
toScroll.setValue(viewRect.x); |
||||||
|
} |
||||||
|
else { |
||||||
|
// rightToLeft scrollbars are oriented with
|
||||||
|
// minValue on the right and maxValue on the
|
||||||
|
// left.
|
||||||
|
int newPos = toScroll.getValue() - |
||||||
|
(viewRect.x - startingX); |
||||||
|
if (newPos < scrollMin) { |
||||||
|
newPos = scrollMin; |
||||||
|
} |
||||||
|
else if (newPos > scrollMax) { |
||||||
|
newPos = scrollMax; |
||||||
|
} |
||||||
|
toScroll.setValue(newPos); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
// Viewport's view is not a Scrollable, or fast wheel
|
||||||
|
// scrolling is not enabled.
|
||||||
|
scrollByUnits(toScroll, direction, |
||||||
|
units, limitScroll); |
||||||
|
} |
||||||
|
} |
||||||
|
else if (e.getScrollType() == |
||||||
|
MouseWheelEvent.WHEEL_BLOCK_SCROLL) { |
||||||
|
scrollByBlock(toScroll, direction); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* Method for scrolling by a unit increment. |
||||||
|
* Added for mouse wheel scrolling support, RFE 4202656. |
||||||
|
* |
||||||
|
* If limitByBlock is set to true, the scrollbar will scroll at least 1 |
||||||
|
* unit increment, but will not scroll farther than the block increment. |
||||||
|
* See BasicScrollPaneUI.Handler.mouseWheelMoved(). |
||||||
|
*/ |
||||||
|
static void scrollByUnits(JScrollBar scrollbar, int direction, |
||||||
|
int units, boolean limitToBlock) { |
||||||
|
// This method is called from BasicScrollPaneUI to implement wheel
|
||||||
|
// scrolling, as well as from scrollByUnit().
|
||||||
|
int delta; |
||||||
|
int limit = -1; |
||||||
|
|
||||||
|
if (limitToBlock) { |
||||||
|
if (direction < 0) { |
||||||
|
limit = scrollbar.getValue() - |
||||||
|
scrollbar.getBlockIncrement(direction); |
||||||
|
} |
||||||
|
else { |
||||||
|
limit = scrollbar.getValue() + |
||||||
|
scrollbar.getBlockIncrement(direction); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
for (int i=0; i<units; i++) { |
||||||
|
if (direction > 0) { |
||||||
|
delta = scrollbar.getUnitIncrement(direction); |
||||||
|
} |
||||||
|
else { |
||||||
|
delta = -scrollbar.getUnitIncrement(direction); |
||||||
|
} |
||||||
|
|
||||||
|
int oldValue = scrollbar.getValue(); |
||||||
|
int newValue = oldValue + delta; |
||||||
|
|
||||||
|
// Check for overflow.
|
||||||
|
if (delta > 0 && newValue < oldValue) { |
||||||
|
newValue = scrollbar.getMaximum(); |
||||||
|
} |
||||||
|
else if (delta < 0 && newValue > oldValue) { |
||||||
|
newValue = scrollbar.getMinimum(); |
||||||
|
} |
||||||
|
if (oldValue == newValue) { |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
if (limitToBlock && i > 0) { |
||||||
|
assert limit != -1; |
||||||
|
if ((direction < 0 && newValue < limit) || |
||||||
|
(direction > 0 && newValue > limit)) { |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
scrollbar.setValue(newValue); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
* Method for scrolling by a block increment. |
||||||
|
* Added for mouse wheel scrolling support, RFE 4202656. |
||||||
|
*/ |
||||||
|
static void scrollByBlock(JScrollBar scrollbar, int direction) { |
||||||
|
// This method is called from BasicScrollPaneUI to implement wheel
|
||||||
|
// scrolling, and also from scrollByBlock().
|
||||||
|
int oldValue = scrollbar.getValue(); |
||||||
|
int blockIncrement = scrollbar.getBlockIncrement(direction); |
||||||
|
int delta = blockIncrement * ((direction > 0) ? +1 : -1); |
||||||
|
int newValue = oldValue + delta; |
||||||
|
|
||||||
|
// Check for overflow.
|
||||||
|
if (delta > 0 && newValue < oldValue) { |
||||||
|
newValue = scrollbar.getMaximum(); |
||||||
|
} |
||||||
|
else if (delta < 0 && newValue > oldValue) { |
||||||
|
newValue = scrollbar.getMinimum(); |
||||||
|
} |
||||||
|
|
||||||
|
scrollbar.setValue(newValue); |
||||||
|
} |
||||||
|
|
||||||
|
public interface ScrollPane { |
||||||
|
boolean isWheelScrollingEnabled(); |
||||||
|
JScrollBar getVerticalScrollBar(); |
||||||
|
JScrollBar getHorizontalScrollBar(); |
||||||
|
JViewport getViewport(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,75 @@ |
|||||||
|
package com.fr.design.mainframe; |
||||||
|
|
||||||
|
import com.fr.common.inputevent.InputEventBaseOnOS; |
||||||
|
|
||||||
|
import javax.swing.JScrollBar; |
||||||
|
import javax.swing.JViewport; |
||||||
|
import java.awt.event.MouseWheelEvent; |
||||||
|
import java.awt.event.MouseWheelListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Starryi |
||||||
|
* @version 1.0 |
||||||
|
* Created by Starryi on 2021/9/24 |
||||||
|
*/ |
||||||
|
public class FormAreaMouseWheelHandler implements MouseWheelListener { |
||||||
|
private final DesignerTranslateMouseWheelHandler translateMouseWheelHandler; |
||||||
|
private final DesignerScaleMouseWheelHandler scaleMouseWheelHandler; |
||||||
|
|
||||||
|
public FormAreaMouseWheelHandler(FormArea formArea) { |
||||||
|
translateMouseWheelHandler = new DesignerTranslateMouseWheelHandler(new FormAreaScrollPaneAdapter(formArea)); |
||||||
|
scaleMouseWheelHandler = new DesignerScaleMouseWheelHandler(new FormAreaScalePaneAdapter(formArea), FormArea.SHOWVALMIN); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseWheelMoved(MouseWheelEvent e) { |
||||||
|
if (InputEventBaseOnOS.isControlDown(e)) { |
||||||
|
scaleMouseWheelHandler.mouseWheelMoved(e); |
||||||
|
} else { |
||||||
|
translateMouseWheelHandler.mouseWheelMoved(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static class FormAreaScalePaneAdapter implements DesignerScaleMouseWheelHandler.ScalePane { |
||||||
|
private final FormArea formArea; |
||||||
|
|
||||||
|
public FormAreaScalePaneAdapter(FormArea formArea) { |
||||||
|
this.formArea = formArea; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JFormSliderPane getSlidePane() { |
||||||
|
return formArea.getSlidePane(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static class FormAreaScrollPaneAdapter implements DesignerTranslateMouseWheelHandler.ScrollPane { |
||||||
|
private final FormArea formArea; |
||||||
|
private final JViewport viewport; |
||||||
|
|
||||||
|
public FormAreaScrollPaneAdapter(FormArea formArea) { |
||||||
|
this.formArea = formArea; |
||||||
|
this.viewport = new JViewport(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isWheelScrollingEnabled() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JScrollBar getVerticalScrollBar() { |
||||||
|
return formArea.getVerticalScrollBar(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JScrollBar getHorizontalScrollBar() { |
||||||
|
return formArea.getHorizontalScrollBar(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JViewport getViewport() { |
||||||
|
return this.viewport; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.fr.design.widget.ui.designer; |
||||||
|
|
||||||
|
import com.fr.base.svg.IconUtils; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Dimension; |
||||||
|
|
||||||
|
public class EmptyLayoutPane extends PredefinedLayoutPane { |
||||||
|
public EmptyLayoutPane() { |
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
this.setPreferredSize(new Dimension(234, 1)); |
||||||
|
this.setBackground(Color.WHITE); |
||||||
|
UILabel newFormIcon = new UILabel(IconUtils.readIcon("/com/fr/design/form/images/new_form.png")); |
||||||
|
newFormIcon.setBorder(BorderFactory.createCompoundBorder( |
||||||
|
BorderFactory.createEmptyBorder(39, 105, 0, 105), |
||||||
|
BorderFactory.createDashedBorder(Color.BLACK, 1.0f, 2.0f, 2.0f, true) |
||||||
|
)); |
||||||
|
UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_New_Empty_Template")); |
||||||
|
label.setBorder(BorderFactory.createEmptyBorder(0, 78, 30, 0)); |
||||||
|
|
||||||
|
this.add(newFormIcon, BorderLayout.NORTH); |
||||||
|
this.add(label, BorderLayout.CENTER); |
||||||
|
|
||||||
|
this.initListener(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getTemplatePath() { |
||||||
|
return StringUtils.EMPTY; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,291 @@ |
|||||||
|
package com.fr.design.widget.ui.designer; |
||||||
|
|
||||||
|
import com.fr.design.border.UITitledMatteBorder; |
||||||
|
import com.fr.design.designer.beans.PredefinedLayout; |
||||||
|
import com.fr.design.designer.beans.models.NewFormModel; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.dialog.DialogActionListener; |
||||||
|
import com.fr.design.dialog.UIDialog; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.gui.icontainer.UIScrollPane; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.BaseJForm; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.form.main.Form; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.stable.bridge.StableFactory; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.DefaultListCellRenderer; |
||||||
|
import javax.swing.DefaultListModel; |
||||||
|
import javax.swing.JList; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.ListSelectionModel; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import javax.swing.event.ListSelectionEvent; |
||||||
|
import javax.swing.event.ListSelectionListener; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.GridLayout; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public class NewFormPane extends BasicPane { |
||||||
|
private NewFormModel newFormModel; |
||||||
|
private UIDialog dialog; |
||||||
|
private PredefinedLayoutPane selectedLayoutPane = null; |
||||||
|
private Map<String, JPanel> layoutPaneMap = new HashMap<>(); |
||||||
|
private List<PredefinedLayoutPane> layoutCards = new ArrayList<>(); |
||||||
|
|
||||||
|
public NewFormPane() { |
||||||
|
newFormModel = NewFormModel.getInstance(); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0)); |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
this.add(createModuleListPane(), BorderLayout.WEST); |
||||||
|
this.add(createTemplateManagePane(), BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Toolkit.i18nText("Fine-Design_New_Template"); |
||||||
|
} |
||||||
|
|
||||||
|
public void showWindow() { |
||||||
|
dialog = new UIDialog(DesignerContext.getDesignerFrame(), this) { |
||||||
|
@Override |
||||||
|
public void checkValid() throws Exception { |
||||||
|
|
||||||
|
} |
||||||
|
}; |
||||||
|
dialog.setButtonEnabled(false); |
||||||
|
dialog.addDialogActionListener(new DialogActionListener() { |
||||||
|
@Override |
||||||
|
public void doOk() { |
||||||
|
if (selectedLayoutPane != null) { |
||||||
|
NewFormPane.this.newForm(selectedLayoutPane.getTemplatePath()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void doCancel() { |
||||||
|
|
||||||
|
} |
||||||
|
}); |
||||||
|
dialog.setSize(new Dimension(900, 600)); |
||||||
|
GUICoreUtils.centerWindow(dialog); |
||||||
|
dialog.setTitle(this.title4PopupWindow()); |
||||||
|
dialog.setResizable(false); |
||||||
|
dialog.setVisible(true); |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createModuleListPane() { |
||||||
|
JList<String> list = new JList<String>(); |
||||||
|
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
||||||
|
list.setModel(initListModel()); |
||||||
|
list.setSelectedIndex(0); |
||||||
|
list.setCellRenderer(new DefaultListCellRenderer() { |
||||||
|
@Override |
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||||
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); |
||||||
|
return this; |
||||||
|
} |
||||||
|
}); |
||||||
|
list.addListSelectionListener(new ListSelectionListener() { |
||||||
|
@Override |
||||||
|
public void valueChanged(ListSelectionEvent e) { |
||||||
|
String value = list.getSelectedValue(); |
||||||
|
int selectedIndex = list.getSelectedIndex(); |
||||||
|
for (Map.Entry<String, JPanel> entry : layoutPaneMap.entrySet()) { |
||||||
|
String moduleName = entry.getKey(); |
||||||
|
JPanel module = entry.getValue(); |
||||||
|
module.setVisible(selectedIndex == 0 || ComparatorUtils.equals(moduleName, value)); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
jPanel.setBackground(new Color(255, 255, 255)); |
||||||
|
jPanel.setPreferredSize(new Dimension(138, 1)); |
||||||
|
jPanel.add(new UIScrollPane(list), BorderLayout.CENTER); |
||||||
|
return jPanel; |
||||||
|
} |
||||||
|
|
||||||
|
private DefaultListModel<String> initListModel() { |
||||||
|
DefaultListModel<String> model = new DefaultListModel<>(); |
||||||
|
model.addElement(Toolkit.i18nText("Fine-Design_All_Template_Layout")); |
||||||
|
Map<String, List<PredefinedLayout>> map = newFormModel.getConfig(); |
||||||
|
for (String key : map.keySet()) { |
||||||
|
model.addElement(key); |
||||||
|
} |
||||||
|
return model; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createTemplateManagePane() { |
||||||
|
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
jPanel.add(createTemplateManageNorthPane(), BorderLayout.NORTH); |
||||||
|
jPanel.add(createTemplateManageSouthPane(), BorderLayout.CENTER); |
||||||
|
return jPanel; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createTemplateManageNorthPane() { |
||||||
|
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); |
||||||
|
jPanel.setPreferredSize(new Dimension(1, 129)); |
||||||
|
jPanel.add(createNewTemplatePane(), BorderLayout.WEST); |
||||||
|
jPanel.add(createSwitchButtonPane(), BorderLayout.EAST); |
||||||
|
return jPanel; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createNewTemplatePane() { |
||||||
|
EmptyLayoutPane jPanel = new EmptyLayoutPane(); |
||||||
|
jPanel.addClickListener(new MouseAdapter() { |
||||||
|
@Override |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
setSelectedLayoutPane(jPanel); |
||||||
|
dialog.setButtonEnabled(true); |
||||||
|
} |
||||||
|
}); |
||||||
|
return jPanel; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createSwitchButtonPane() { |
||||||
|
UIButtonGroup<String> buttonGroup = new UIButtonGroup<String>(new String[] { |
||||||
|
Toolkit.i18nText("Fine-Design_Simple_Style_Template"), |
||||||
|
Toolkit.i18nText("Fine-Design_Real_Style_Template") |
||||||
|
}); |
||||||
|
buttonGroup.setPreferredSize(new Dimension(140, 20)); |
||||||
|
buttonGroup.setSelectedIndex(1); |
||||||
|
buttonGroup.addChangeListener(new ChangeListener() { |
||||||
|
@Override |
||||||
|
public void stateChanged(ChangeEvent e) { |
||||||
|
int selectedIndex = buttonGroup.getSelectedIndex(); |
||||||
|
for (PredefinedLayoutPane layoutCard : layoutCards) { |
||||||
|
if (selectedIndex == 1) { |
||||||
|
layoutCard.showRealStyle(); |
||||||
|
} else { |
||||||
|
layoutCard.showSimpleStyle(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
JPanel switchButtonPane = new JPanel(new BorderLayout()); |
||||||
|
switchButtonPane.add(buttonGroup, BorderLayout.CENTER); |
||||||
|
|
||||||
|
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); |
||||||
|
jPanel.add(switchButtonPane, BorderLayout.NORTH); |
||||||
|
return jPanel; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createTemplateManageSouthPane() { |
||||||
|
List<JPanel> predefinedLayoutPanes = createPredefinedLayoutPanes(); |
||||||
|
JPanel selectionsPane = createSelectionsPane(predefinedLayoutPanes); |
||||||
|
|
||||||
|
UIScrollPane selectionsScrollPane = new UIScrollPane(selectionsPane); |
||||||
|
selectionsScrollPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); |
||||||
|
|
||||||
|
JPanel titlePane = new JPanel(new BorderLayout()); |
||||||
|
titlePane.setBorder(UITitledMatteBorder.createTitledBorder(Toolkit.i18nText("Fine-Design_Select_Template"), new Color(1, 159, 222))); |
||||||
|
titlePane.add(selectionsScrollPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
jPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0)); |
||||||
|
jPanel.add(titlePane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
return jPanel; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createSelectionsPane(List<JPanel> components) { |
||||||
|
JPanel selectionsPane = new JPanel(); |
||||||
|
JPanel container = new JPanel(new BorderLayout()); |
||||||
|
for (int i = 0; i < components.size(); i++) { |
||||||
|
JPanel component = components.get(i); |
||||||
|
if (component != null) { |
||||||
|
container.add(component, BorderLayout.NORTH); |
||||||
|
JPanel nextContainer = new JPanel(new BorderLayout()); |
||||||
|
container.add(nextContainer, BorderLayout.CENTER); |
||||||
|
if (i == 0) { |
||||||
|
selectionsPane = container; |
||||||
|
} |
||||||
|
container = nextContainer; |
||||||
|
} |
||||||
|
} |
||||||
|
return selectionsPane; |
||||||
|
} |
||||||
|
|
||||||
|
private List<JPanel> createPredefinedLayoutPanes() { |
||||||
|
List<JPanel> jPanels = new ArrayList<>(); |
||||||
|
Map<String, List<PredefinedLayout>> map = newFormModel.getConfig(); |
||||||
|
for (Map.Entry<String, List<PredefinedLayout>> entry : map.entrySet()) { |
||||||
|
String moduleName = entry.getKey(); |
||||||
|
List<PredefinedLayout> layouts = entry.getValue(); |
||||||
|
|
||||||
|
JPanel module = createPredefinedLayoutPane(moduleName); |
||||||
|
layoutPaneMap.put(moduleName, module); |
||||||
|
for (PredefinedLayout layout : layouts) { |
||||||
|
PredefinedLayoutPane predefinedLayoutPane = new PredefinedLayoutPane(layout); |
||||||
|
predefinedLayoutPane.addClickListener(new MouseAdapter() { |
||||||
|
@Override |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
setSelectedLayoutPane(predefinedLayoutPane); |
||||||
|
dialog.setButtonEnabled(true); |
||||||
|
} |
||||||
|
}); |
||||||
|
module.add(predefinedLayoutPane); |
||||||
|
layoutCards.add(predefinedLayoutPane); |
||||||
|
} |
||||||
|
jPanels.add(module); |
||||||
|
} |
||||||
|
return jPanels; |
||||||
|
} |
||||||
|
|
||||||
|
private JPanel createPredefinedLayoutPane(String title) { |
||||||
|
JPanel jp = new JPanel(); |
||||||
|
UITitledMatteBorder explainBorder = UITitledMatteBorder.createTitledTopBorder(title, Color.BLACK); |
||||||
|
jp.setBorder(explainBorder); |
||||||
|
jp.setLayout(new GridLayout(0, 3, 5, 5)); |
||||||
|
return jp; |
||||||
|
} |
||||||
|
|
||||||
|
private void newForm(String path) { |
||||||
|
BaseJForm jForm; |
||||||
|
try { |
||||||
|
if (StringUtils.isNotEmpty(path)) { |
||||||
|
Form form = new Form(); |
||||||
|
form.readStream(NewFormPane.class.getResourceAsStream(path)); |
||||||
|
jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, new Object[]{form}, BaseJForm.class); |
||||||
|
} else { |
||||||
|
jForm = StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG, BaseJForm.class); |
||||||
|
} |
||||||
|
DesignerContext.getDesignerFrame().addAndActivateJTemplate((JTemplate<?, ?>) jForm); |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void setSelectedLayoutPane(PredefinedLayoutPane layoutPane) { |
||||||
|
if (selectedLayoutPane != layoutPane) { |
||||||
|
if (selectedLayoutPane != null) { |
||||||
|
selectedLayoutPane.setSelected(false); |
||||||
|
} |
||||||
|
selectedLayoutPane = layoutPane; |
||||||
|
if (selectedLayoutPane != null) { |
||||||
|
selectedLayoutPane.setSelected(true); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,117 @@ |
|||||||
|
package com.fr.design.widget.ui.designer; |
||||||
|
|
||||||
|
import com.fr.base.GraphHelper; |
||||||
|
import com.fr.base.svg.IconUtils; |
||||||
|
import com.fr.design.designer.beans.PredefinedLayout; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.mainframe.share.ui.base.MouseClickListener; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.CardLayout; |
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Graphics; |
||||||
|
import java.awt.Rectangle; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
|
||||||
|
public class PredefinedLayoutPane extends JPanel { |
||||||
|
private static final Color HOVERING_BORDER_COLOR = new Color(65, 155, 249); |
||||||
|
private static final Color HOVERING_SHADOW_COLOR = new Color(65, 155, 249, 51); |
||||||
|
private CardLayout cardLayout = new CardLayout(); |
||||||
|
protected boolean hovering = false; |
||||||
|
protected boolean selected = false; |
||||||
|
protected MouseAdapter clickListener; |
||||||
|
protected String templatePath = StringUtils.EMPTY; |
||||||
|
|
||||||
|
public PredefinedLayoutPane() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public PredefinedLayoutPane(PredefinedLayout predefinedLayout) { |
||||||
|
this.templatePath = predefinedLayout.getTemplate(); |
||||||
|
UILabel simpleStyle = new UILabel(IconUtils.readIcon(predefinedLayout.getSimpleStyle())); |
||||||
|
UILabel realStyle = new UILabel(IconUtils.readIcon(predefinedLayout.getRealStyle())); |
||||||
|
|
||||||
|
this.setLayout(cardLayout); |
||||||
|
this.add(realStyle, 0); |
||||||
|
this.add(simpleStyle, 1); |
||||||
|
this.initListener(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void initListener() { |
||||||
|
this.addMouseListener(new MouseClickListener() { |
||||||
|
@Override |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
if (clickListener != null) { |
||||||
|
clickListener.mouseClicked(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseEntered(MouseEvent e) { |
||||||
|
hovering = true; |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void mouseExited(MouseEvent e) { |
||||||
|
hovering = false; |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paint(Graphics g) { |
||||||
|
super.paint(g); |
||||||
|
if (hovering) { |
||||||
|
g.setColor(HOVERING_SHADOW_COLOR); |
||||||
|
GraphHelper.fillRect(g, 1, 1, this.getWidth() - 2, this.getHeight() - 2); |
||||||
|
} |
||||||
|
|
||||||
|
if (selected || hovering) { |
||||||
|
g.setColor(HOVERING_BORDER_COLOR); |
||||||
|
Rectangle rectangle = new Rectangle(1, 1, this.getWidth() - 2, this.getHeight() - 2); |
||||||
|
GraphHelper.draw(g, rectangle, Constants.LINE_MEDIUM); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void addClickListener(MouseAdapter clickListener) { |
||||||
|
this.clickListener = clickListener; |
||||||
|
} |
||||||
|
|
||||||
|
public void showSimpleStyle() { |
||||||
|
cardLayout.last(this); |
||||||
|
} |
||||||
|
|
||||||
|
public void showRealStyle() { |
||||||
|
cardLayout.first(this); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isHovering() { |
||||||
|
return hovering; |
||||||
|
} |
||||||
|
|
||||||
|
public void setHovering(boolean hovering) { |
||||||
|
this.hovering = hovering; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isSelected() { |
||||||
|
return selected; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSelected(boolean selected) { |
||||||
|
this.selected = selected; |
||||||
|
repaint(); |
||||||
|
} |
||||||
|
|
||||||
|
public String getTemplatePath() { |
||||||
|
return templatePath; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTemplatePath(String templatePath) { |
||||||
|
this.templatePath = templatePath; |
||||||
|
} |
||||||
|
} |
After Width: | Height: | Size: 449 B |
After Width: | Height: | Size: 159 B |
After Width: | Height: | Size: 201 B |
After Width: | Height: | Size: 261 B |
@ -0,0 +1,100 @@ |
|||||||
|
{ |
||||||
|
"config":{ |
||||||
|
"2-4模块":[ |
||||||
|
{ |
||||||
|
"template":"2-4/1.frm", |
||||||
|
"realStyle":"real_style_1", |
||||||
|
"simpleStyle":"simple_style_1" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"2-4/2.frm", |
||||||
|
"realStyle":"real_style_2", |
||||||
|
"simpleStyle":"simple_style_2" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"2-4/3.frm", |
||||||
|
"realStyle":"real_style_3", |
||||||
|
"simpleStyle":"simple_style_3" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"2-4/4.frm", |
||||||
|
"realStyle":"real_style_4", |
||||||
|
"simpleStyle":"simple_style_4" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"2-4/5.frm", |
||||||
|
"realStyle":"real_style_5", |
||||||
|
"simpleStyle":"simple_style_5" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"2-4/6.frm", |
||||||
|
"realStyle":"real_style_6", |
||||||
|
"simpleStyle":"simple_style_6" |
||||||
|
} |
||||||
|
], |
||||||
|
"5-7模块":[ |
||||||
|
{ |
||||||
|
"template":"5-7/1.frm", |
||||||
|
"realStyle":"real_style_7", |
||||||
|
"simpleStyle":"simple_style_7" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"5-7/2.frm", |
||||||
|
"realStyle":"real_style_8", |
||||||
|
"simpleStyle":"simple_style_8" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"5-7/3.frm", |
||||||
|
"realStyle":"real_style_9", |
||||||
|
"simpleStyle":"simple_style_9" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"5-7/4.frm", |
||||||
|
"realStyle":"real_style_10", |
||||||
|
"simpleStyle":"simple_style_10" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"5-7/5.frm", |
||||||
|
"realStyle":"real_style_11", |
||||||
|
"simpleStyle":"simple_style_11" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"5-7/6.frm", |
||||||
|
"realStyle":"real_style_12", |
||||||
|
"simpleStyle":"simple_style_12" |
||||||
|
} |
||||||
|
], |
||||||
|
"多模块":[ |
||||||
|
{ |
||||||
|
"template":"multi/1.frm", |
||||||
|
"realStyle":"real_style_13", |
||||||
|
"simpleStyle":"simple_style_13" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"multi/2.frm", |
||||||
|
"realStyle":"real_style_14", |
||||||
|
"simpleStyle":"simple_style_14" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"multi/3.frm", |
||||||
|
"realStyle":"real_style_15", |
||||||
|
"simpleStyle":"simple_style_15" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"multi/4.frm", |
||||||
|
"realStyle":"real_style_16", |
||||||
|
"simpleStyle":"simple_style_16" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"multi/5.frm", |
||||||
|
"realStyle":"real_style_17", |
||||||
|
"simpleStyle":"simple_style_17" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"template":"multi/6.frm", |
||||||
|
"realStyle":"real_style_18", |
||||||
|
"simpleStyle":"simple_style_18" |
||||||
|
} |
||||||
|
] |
||||||
|
} |
||||||
|
} |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 42 KiB |