diff --git a/designer_base/src/com/fr/design/mainframe/HelpDialogManager.java b/designer_base/src/com/fr/design/mainframe/HelpDialogManager.java index 5de971b71c..febda0a851 100644 --- a/designer_base/src/com/fr/design/mainframe/HelpDialogManager.java +++ b/designer_base/src/com/fr/design/mainframe/HelpDialogManager.java @@ -35,11 +35,4 @@ public class HelpDialogManager { } return THIS; } - - public void destroyDialog() { - if (handler != null) { - handler.destroyHelpDialog(); - } - handler = null; - } } diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 4e1d1decd1..8df23d70d9 100644 --- a/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -138,8 +138,6 @@ public abstract class ToolBarMenuDock { // 添加帮助菜单 menuList.add(createHelpMenuDef()); - // 添加社区菜单 - menuList.add(createCommunityMenuDef()); return menuList.toArray(new MenuDef[menuList.size()]); } diff --git a/designer_chart/src/com/fr/design/chart/ChartPlotFactory.java b/designer_chart/src/com/fr/design/chart/ChartPlotFactory.java index 48e018a598..aeb780add1 100644 --- a/designer_chart/src/com/fr/design/chart/ChartPlotFactory.java +++ b/designer_chart/src/com/fr/design/chart/ChartPlotFactory.java @@ -72,7 +72,7 @@ public class ChartPlotFactory { .setAxisPaneCls(XYChartStyleAxisPane.class) .setDataLabelPaneClass(XYDataLabelPane.class)); map.put(FunnelPlot.class.getName(), new FactoryObject() - .setDataLabelPaneClass(PieDataLabelPane.class)); + .setDataLabelPaneClass(FunnelDataLabelPane.class)); } private ChartPlotFactory() { diff --git a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/FunnelDataLabelPane.java b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/FunnelDataLabelPane.java new file mode 100644 index 0000000000..14b0c18ad2 --- /dev/null +++ b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/FunnelDataLabelPane.java @@ -0,0 +1,13 @@ +package com.fr.design.chart.series.SeriesCondition.dlp; + +import java.awt.*; + +/** + * Created by Mitisky on 16/11/9. + */ +public class FunnelDataLabelPane extends DataLabelPane { + @Override + protected Component[] createComponents4ShowCategoryName() { + return new Component[0]; + } +} diff --git a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/FunnelPlotDataSeriesConditionPane.java b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/FunnelPlotDataSeriesConditionPane.java new file mode 100644 index 0000000000..99469ff3cf --- /dev/null +++ b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/FunnelPlotDataSeriesConditionPane.java @@ -0,0 +1,28 @@ +package com.fr.design.chart.series.SeriesCondition.impl; + +import com.fr.chart.chartattr.FunnelPlot; +import com.fr.chart.chartattr.Plot; +import com.fr.design.chart.series.SeriesCondition.ChartConditionPane; +import com.fr.design.chart.series.SeriesCondition.DataSeriesConditionPane; +import com.fr.design.chart.series.SeriesCondition.PiePlotChartConditionPane; + +/** + * Created by Mitisky on 16/11/9. + */ +public class FunnelPlotDataSeriesConditionPane extends DataSeriesConditionPane { + + @Override + protected ChartConditionPane createListConditionPane() { + return new PiePlotChartConditionPane(); + } + + /** + * 返回class对象 + * @return class对象 + */ + @Override + public Class class4Correspond() { + return FunnelPlot.class; + } + +} diff --git a/designer_chart/src/com/fr/design/chartinterface/FunnelIndependentChartInterface.java b/designer_chart/src/com/fr/design/chartinterface/FunnelIndependentChartInterface.java index 43c71b46c2..00891e628c 100644 --- a/designer_chart/src/com/fr/design/chartinterface/FunnelIndependentChartInterface.java +++ b/designer_chart/src/com/fr/design/chartinterface/FunnelIndependentChartInterface.java @@ -3,6 +3,8 @@ package com.fr.design.chartinterface; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; import com.fr.design.chart.fun.impl.AbstractIndependentChartUIWithAPILevel; +import com.fr.design.chart.series.SeriesCondition.impl.FunnelPlotDataSeriesConditionPane; +import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; @@ -34,6 +36,10 @@ public class FunnelIndependentChartInterface extends AbstractIndependentChartUIW return new FunnelSeriesPane(parent, plot); } + public ConditionAttributesPane getPlotConditionPane(Plot plot){ + return new FunnelPlotDataSeriesConditionPane(); + } + /** *图标路径 * @return 图标路径 diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index 8ee4e4667f..8d9ed81530 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -1,10 +1,10 @@ package com.fr.design.mainframe.chart.gui; import com.fr.base.BaseUtils; +import com.fr.chart.base.AttrChangeConfig; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.SwitchState; -import com.fr.chart.base.AttrChangeConfig; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.DialogActionListener; import com.fr.design.dialog.UIDialog; @@ -53,19 +53,14 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private ChartTypePane parent = null; - //记录鼠标当前是否在操作添加按钮 - private boolean mouseOnChartTypeButtonPane = false; - //配置窗口属性 private UIMenuNameableCreator configCreator; - /** - * 鼠标事件是否在这个面板 - * @return 返回是否 - */ - public boolean isMouseOnChartTypeButtonPane() { - return this.mouseOnChartTypeButtonPane; - } + //处理 编辑一个button时,选中另一个button的问题. + //stopEditing不能直接relayout,否则click事件不响应了. + //所以:stopEditing--选中其他button则响应click之后relayout;普通失焦则直接relayout. + private boolean pressOtherButtonWhenEditing = false; + // private AWTEventListener awt = new AWTEventListener() { // public void eventDispatched(AWTEvent event) { @@ -122,7 +117,6 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private void initAddButton() { addButton.setPreferredSize(new Dimension(20, 20)); addButton.addActionListener(addListener); - addButton.addMouseListener(mouseListener); } private void initConfigButton() { @@ -133,7 +127,6 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen ActionListener addListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - mouseOnChartTypeButtonPane = true; String name = getNewChartName(); ChartChangeButton button = new ChartChangeButton(name);// some set selected @@ -188,15 +181,6 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen dialog.setVisible(true); } }; - - - MouseListener mouseListener = new MouseAdapter() { - @Override - public void mouseExited(MouseEvent e) { - super.mouseExited(e); - mouseOnChartTypeButtonPane = false; - } - }; private String getNewChartName() { int count = indexList.size() + 1; @@ -352,12 +336,19 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen if (currentEditingEditor != null) { String newName = currentEditingEditor.getText(); int selectedIndex = editingCollection.getSelectedIndex(); + ChartChangeButton button = indexList.get(selectedIndex); + button.isMoveOn = false; if (!ComparatorUtils.equals(editingCollection.getChartName(selectedIndex), newName)) { editingCollection.setChartName(selectedIndex, newName); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified(); + button.changeChartName(newName); } buttonPane.remove(currentEditingEditor); currentEditingEditor = null; + + if(!pressOtherButtonWhenEditing) { + layoutPane(buttonPane); + } } } @@ -375,11 +366,25 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen buttonName = name; this.setToolTipText(name); - nameField.addActionListener(new ActionListener() { + nameField.addActionListener(new ActionListener() {//enter @Override public void actionPerformed(ActionEvent e) { + pressOtherButtonWhenEditing = false; stopEditing(); - populateBean(editingCollection); + } + }); + + nameField.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + + } + + @Override + public void focusLost(FocusEvent e) {//编辑状态lost才走这边 + if (currentEditingEditor != null ) { + stopEditing(); + } } }); } @@ -388,6 +393,11 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen return buttonName; } + private void changeChartName(String name) { + this.setText(name); + buttonName = name; + } + public Dimension getPreferredSize() { return new Dimension(B_W, B_H); } @@ -467,17 +477,20 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen @Override public void mouseClicked(MouseEvent e) { mouseClick(e); - mouseOnChartTypeButtonPane = true; + if(pressOtherButtonWhenEditing){ + relayoutPane(); + pressOtherButtonWhenEditing = false; + } } public void mouseEntered(MouseEvent e) { checkMoveOn(true); - mouseOnChartTypeButtonPane = true; + pressOtherButtonWhenEditing = currentEditingEditor != null; } public void mouseExited(MouseEvent e) { checkMoveOn(false); - mouseOnChartTypeButtonPane = false; + pressOtherButtonWhenEditing = false; } }; } diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java index c49ecf0f38..3ab61eb38b 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java @@ -308,19 +308,23 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { * @param y 坐标y */ public void fix(XCreator creator ,int x, int y) { + int height = creator.getHeight(); + int width = creator.getWidth(); if (x < 0) { + width += x; x = 0; } else if (x + creator.getWidth() > container.getWidth()) { - x = container.getWidth() - creator.getWidth(); + width = container.getWidth() - x; } if (y < 0) { + height += y; y = 0; } else if (y + creator.getHeight() > container.getHeight()) { - y = container.getHeight() - creator.getHeight(); + height = container.getHeight() - y; } - creator.setLocation(x, y); + creator.setBounds(x, y, width, height); } @Override diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index daf6e2dbc9..e02dbd8fc9 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -1,5 +1,5 @@ /** - * + * */ package com.fr.design.designer.beans.adapters.layout; @@ -24,6 +24,7 @@ import com.fr.design.designer.properties.FRFitLayoutConstraints; import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.JForm; +import com.fr.design.utils.ComponentUtils; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WLayout; @@ -32,620 +33,666 @@ import com.fr.general.ComparatorUtils; /** * 自适应布局的容器适配器 - * + * * @author jim * @date 2014-6-24 */ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { - - public static final String WIDGETPANEICONPATH="/com/fr/web/images/form/resources/layout_absolute.png"; - private static final int DEPENDING_SCOPE = 3; - private HoverPainter painter; - - /** - * 构造函数 - * @param container XWFitLayout容器 - */ - public FRFitLayoutAdapter(XLayoutContainer container) { - super(container); - painter = new FRFitLayoutPainter(container); - initMinSize(); - } - - private void initMinSize() { - XWFitLayout layout = (XWFitLayout) container; - minWidth = layout.getActualMinWidth(); - minHeight = layout.getActualMinHeight(); - actualVal = layout.getAcualInterval(); - margin = layout.toData().getMargin(); - } - - @Override - public HoverPainter getPainter() { - return painter; - } - - /** - * 返回布局自身属性,方便一些特有设置在layout刷新时处理 - */ - @Override + + public static final String WIDGETPANEICONPATH = "/com/fr/web/images/form/resources/layout_absolute.png"; + private static final int DEPENDING_SCOPE = 3; + private HoverPainter painter; + + /** + * 构造函数 + * + * @param container XWFitLayout容器 + */ + public FRFitLayoutAdapter(XLayoutContainer container) { + super(container); + painter = new FRFitLayoutPainter(container); + initMinSize(); + } + + private void initMinSize() { + XWFitLayout layout = (XWFitLayout) container; + minWidth = layout.getActualMinWidth(); + minHeight = layout.getActualMinHeight(); + actualVal = layout.getAcualInterval(); + margin = layout.toData().getMargin(); + } + + @Override + public HoverPainter getPainter() { + return painter; + } + + /** + * 返回布局自身属性,方便一些特有设置在layout刷新时处理 + */ + @Override public GroupModel getLayoutProperties() { - XWFitLayout xfl = (XWFitLayout) container; + XWFitLayout xfl = (XWFitLayout) container; return new FRFitLayoutPropertiesGroupModel(xfl); } - - /** - * 添加组件 - * - * @param child 待添加的组件 - *@param x 坐标x - *@param y 坐标y - */ - @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(); + + /** + * 添加组件 + * + * @param child 待添加的组件 + * @param x 坐标x + * @param y 坐标y + */ + @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(); + } + + public 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()); + } + } + + + private void addParentCreator(XCreator child) { + XLayoutContainer parentPanel = child.initCreatorWrapper(minHeight); + container.add(parentPanel, child.toData().getWidgetName()); } - - public void updateCreatorBackBound() { - for (int i=0,size=container.getComponentCount(); i= minWidth * 2 + actualVal; - boolean verticalValid = componentHeight >= minHeight * 2 + actualVal; - return y > upHeight && y < downHeight ? horizonValid : verticalValid; + // 计算是否能拖入鼠标区域时,会用到fix 的方法 + isFindRelatedComps = false; + //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域 + Component comp = container.getComponentAt(x, y); + if (checkInterval(comp)) { + return false; + } + //如果当前处于边缘地带, 那么就把他贴到父容器上 + boolean isMatchEdge = matchEdge(x, y); + + int componentHeight = comp.getHeight(); + int componentWidth = comp.getWidth(); + //上半部分高度 + int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY(); + //下半部分高度 + int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY(); + + //布局控件要先判断是不是可编辑 + XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout(); + if (topLayout != null && !isMatchEdge && !topLayout.isEditable()) { + return false; + } + + if (isCrossPointArea(comp, x, y)) { + return canAcceptWhileCrossPoint(comp, x, y); + } + + if (isTrisectionArea(comp, x, y)) { + return canAcceptWhileTrisection(comp, x, y); + } + + boolean horizonValid = componentWidth >= minWidth * 2 + actualVal; + boolean verticalValid = componentHeight >= minHeight * 2 + actualVal; + return y > upHeight && y < downHeight ? horizonValid : verticalValid; } - + // 间隔区域 - private boolean checkInterval(Component comp){ - return container.getComponentCount()>0 && comp == container; + private boolean checkInterval(Component comp) { + return container.getComponentCount() > 0 && comp == container; } - + /** * 是否在组件边缘 + * * @param x 横坐标 * @param y 纵坐标 * @return 是否在组件边缘 */ - public boolean matchEdge(int x, int y){ - if(intersectsEdge(x, y,container)){ - //寻找最近的fit, 在边缘地段添加的控件, 将其送给该fit - XLayoutContainer parent = container.findNearestFit(); - container = parent != null ? parent : container; - return true; - } - return false; + public boolean matchEdge(int x, int y) { + if (intersectsEdge(x, y, container)) { + //寻找最近的fit, 在边缘地段添加的控件, 将其送给该fit + XLayoutContainer parent = container.findNearestFit(); + container = parent != null ? parent : container; + return true; + } + return false; } - - /** - * 是否在组件边缘 - * @param x 横坐标 - * @param y 纵坐标 - * @param container 参照组件 - * @return 是否在组件边缘 - */ + + /** + * 是否在组件边缘 + * + * @param x 横坐标 + * @param y 纵坐标 + * @param container 参照组件 + * @return 是否在组件边缘 + */ //是否包含于边缘地段, 按顺序上, 下, 左, 右检测 - public boolean intersectsEdge(int x, int y,XLayoutContainer container) { - int containerX = container.getX(); - int containerY = container.getY(); - int containerWidth = container.getWidth(); - int containerHeight = container.getHeight(); - - // 当前坐标点 - Rectangle currentXY = new Rectangle(x, y, 1, 1); - // 上边缘 - Rectangle upEdge = new Rectangle(containerX, containerY, containerWidth, BORDER_PROPORTION); - if(upEdge.intersects(currentXY)){ - return true; - } - - int bottomY = containerY + containerHeight - BORDER_PROPORTION; - // 下边缘 - Rectangle bottomEdge = new Rectangle(containerX, bottomY, containerWidth, BORDER_PROPORTION); - if(bottomEdge.intersects(currentXY)){ - return true; - } - - //左右边缘的高度 -10*2 是为了不和上下边缘重合 - int verticalHeight = containerHeight - BORDER_PROPORTION * 2; - int leftY = containerY + BORDER_PROPORTION; - // 左边缘 - Rectangle leftEdge = new Rectangle(containerX, leftY, BORDER_PROPORTION, verticalHeight); - if(leftEdge.intersects(currentXY)){ - return true; - } - - int rightY = containerY + BORDER_PROPORTION; - int rightX = containerX + containerWidth - BORDER_PROPORTION; - // 右边缘 - Rectangle rightEdge = new Rectangle(rightX, rightY, BORDER_PROPORTION, verticalHeight); - return rightEdge.intersects(currentXY); - } - + public boolean intersectsEdge(int x, int y, XLayoutContainer container) { + int containerX = container.getX(); + int containerY = container.getY(); + int containerWidth = container.getWidth(); + int containerHeight = container.getHeight(); + + // 当前坐标点 + Rectangle currentXY = new Rectangle(x, y, 1, 1); + // 上边缘 + Rectangle upEdge = new Rectangle(containerX, containerY, containerWidth, BORDER_PROPORTION); + if (upEdge.intersects(currentXY)) { + return true; + } + + int bottomY = containerY + containerHeight - BORDER_PROPORTION; + // 下边缘 + Rectangle bottomEdge = new Rectangle(containerX, bottomY, containerWidth, BORDER_PROPORTION); + if (bottomEdge.intersects(currentXY)) { + return true; + } + + //左右边缘的高度 -10*2 是为了不和上下边缘重合 + int verticalHeight = containerHeight - BORDER_PROPORTION * 2; + int leftY = containerY + BORDER_PROPORTION; + // 左边缘 + Rectangle leftEdge = new Rectangle(containerX, leftY, BORDER_PROPORTION, verticalHeight); + if (leftEdge.intersects(currentXY)) { + return true; + } + + int rightY = containerY + BORDER_PROPORTION; + int rightX = containerX + containerWidth - BORDER_PROPORTION; + // 右边缘 + Rectangle rightEdge = new Rectangle(rightX, rightY, BORDER_PROPORTION, verticalHeight); + return rightEdge.intersects(currentXY); + } + /** * 交叉点区域时,能否对应位置放入组件 */ protected boolean canAcceptWhileCrossPoint(Component comp, int x, int y) { - return super.canAcceptWhileCrossPoint(comp, x, y); + return super.canAcceptWhileCrossPoint(comp, x, y); } protected boolean canAcceptWhileTrisection(Component comp, int x, int y) { - return super.canAcceptWhileTrisection(comp, x, y); + return super.canAcceptWhileTrisection(comp, x, y); } - + /** * 判断是否鼠标在组件的三等分区域,如果组件在布局管理器中间,上下左右都可能会三等分 + * * @param parentComp 鼠标所在区域的组件 - * @param x 坐标x - * @param y 坐标y + * @param x 坐标x + * @param y 坐标y * @return 是则返回true */ public boolean isTrisectionArea(Component parentComp, int x, int y) { - return super.isTrisectionArea(parentComp, x, y); + return super.isTrisectionArea(parentComp, x, y); } - + /** * 是否为组件交叉点区域 或者是相邻三组建中间点 + * * @param currentComp 当前组件 - * @param x 坐标x - * @param y 坐标y + * @param x 坐标x + * @param y 坐标y * @return 是则返回true */ public boolean isCrossPointArea(Component currentComp, int x, int y) { - return super.isCrossPointArea(currentComp, x, y); + return super.isCrossPointArea(currentComp, x, y); } protected void initCompsList() { - super.initCompsList(); + super.initCompsList(); } protected void clearCompsList() { - super.clearCompsList(); + super.clearCompsList(); } - private Rectangle adjustBackupBound(Rectangle backupBound,XWCardMainBorderLayout mainLayout){ - // 参数界面高度对纵坐标产生的影响 - JForm jform = (JForm)(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); - if(jform.getFormDesign().getParaComponent()!= null){ - backupBound.y -= jform.getFormDesign().getParaHeight(); - } - - Rectangle rec = mainLayout.getBounds(); - // XWTabLayout里面的横纵坐标收到外层XWCardMainBorderLayout的横纵坐标影响 - // 减掉之后可以按照它原来的逻辑执行 - backupBound.x -= rec.x; - backupBound.y -= rec.y; - XWCardLayout cardLayout = mainLayout.getCardPart(); - LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); - // 当tab布局为标题样式时,才需要处理标题栏高度产生的影响 - if(ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)){ - backupBound.y -= WCardMainBorderLayout.TAB_HEIGHT; - } - return backupBound; + + private Rectangle adjustBackupBound(Rectangle backupBound, XWCardMainBorderLayout mainLayout) { + // 参数界面高度对纵坐标产生的影响 + JForm jform = (JForm) (HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + if (jform.getFormDesign().getParaComponent() != null) { + backupBound.y -= jform.getFormDesign().getParaHeight(); + } + + Rectangle rec = mainLayout.getBounds(); + // XWTabLayout里面的横纵坐标收到外层XWCardMainBorderLayout的横纵坐标影响 + // 减掉之后可以按照它原来的逻辑执行 + backupBound.x -= rec.x; + backupBound.y -= rec.y; + XWCardLayout cardLayout = mainLayout.getCardPart(); + LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); + // 当tab布局为标题样式时,才需要处理标题栏高度产生的影响 + if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { + backupBound.y -= WCardMainBorderLayout.TAB_HEIGHT; + } + return backupBound; } - + /** * 拖拽控件边框后,根据控件的大小尺寸,进行相关组件的调整 + * * @param creator 组件 */ @Override public void fix(XCreator creator) { - //拖拽组件原大小、位置 - Rectangle backupBound = creator.getBackupBound(); - backupBound.x -= container.getX(); - backupBound.y -= container.getY(); - //当前拖拽组件的位置 - int x = creator.getX(); - int y = creator.getY(); - - // 获取容器所有内部组件横坐标 - int[] posXs = container.getHors(); - // 获取容器所有内部组件纵坐标 - int[] posYs = container.getVeris(); - - XLayoutContainer outerLayout = container.getOuterLayout(); - if(!ComparatorUtils.equals(outerLayout, container.getBackupParent())){ - XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout)outerLayout; - backupBound = adjustBackupBound(backupBound, mainLayout); - } - - //拖拽组件拖拽以后的大小 - int w = creator.getWidth(); - int h = creator.getHeight(); - initCompsList(); - creator.setBounds(backupBound); - int difference = 0; - if (x!=backupBound.x) { - dealLeft(backupBound, x, posXs, difference, creator); - } else if(w!=backupBound.width) { - dealRight(backupBound, x, w, posXs, difference, creator); - } else if (y!=backupBound.y) { - dealTop(backupBound, y, posYs, difference, creator); - } else if (h!=backupBound.height) { - dealButtom(backupBound, y, h, posYs, difference, creator); - } - clearCompsList(); - XWFitLayout layout = (XWFitLayout) container; - layout.updateBoundsWidget(); // 更新对应的BoundsWidget - updateCreatorBackBound(); + //拖拽组件原大小、位置 + Rectangle backupBound = creator.getBackupBound(); + backupBound.x -= container.getX(); + backupBound.y -= container.getY(); + //当前拖拽组件的位置 + int x = creator.getX(); + int y = creator.getY(); + + // 获取容器所有内部组件横坐标 + int[] posXs = container.getHors(); + // 获取容器所有内部组件纵坐标 + int[] posYs = container.getVeris(); + + XLayoutContainer outerLayout = container.getOuterLayout(); + if (!ComparatorUtils.equals(outerLayout, container.getBackupParent())) { + XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) outerLayout; + backupBound = adjustBackupBound(backupBound, mainLayout); + } + + //拖拽组件拖拽以后的大小 + int w = creator.getWidth(); + int h = creator.getHeight(); + initCompsList(); + creator.setBounds(backupBound); + int difference = 0; + if (x != backupBound.x) { + dealLeft(backupBound, x, posXs, difference, creator); + } else if (w != backupBound.width) { + dealRight(backupBound, x, w, posXs, difference, creator); + } else if (y != backupBound.y) { + dealTop(backupBound, y, posYs, difference, creator); + } else if (h != backupBound.height) { + dealButtom(backupBound, y, h, posYs, difference, creator); + } + clearCompsList(); + XWFitLayout layout = (XWFitLayout) container; + layout.updateBoundsWidget(); // 更新对应的BoundsWidget + updateCreatorBackBound(); } - - private void dealLeft(Rectangle backupBound,int x,int[] posXs,int difference,XCreator creator){ - if (backupBound.x == margin.getLeft()) { - return; - } - x = adjustCoordinateByDependingLine(x,posXs); - difference = x-backupBound.x; - dealDirectionAtLeft(backupBound, difference, creator); + + /** + * 拖拽控件边框后,根据控件的大小尺寸,进行相关组件的调整 + * + * @param backupBound 边界备份 + * @param bounds 组件边界 + * @param xCreator 组件 + * @param row 选中的行 + * @param difference 偏移量 + */ + public void calculateBounds(Rectangle backupBound, Rectangle bounds, XCreator xCreator, int row, int difference) { + Rectangle rc = new Rectangle(0,0,0,0); + XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator); + if (parent != null) { + Rectangle rec = ComponentUtils.getRelativeBounds(parent); + rc.x = rec.x; + rc.y = rec.y; + } + int x = backupBound.x - rc.x, y = backupBound.y - rc.y; + //处理左右延伸 + switch (row) { + case 0: + if (backupBound.width + backupBound.x == container.getWidth() - margin.getRight() +rc.x) { + x += difference; + } + break; + case 1: + if(backupBound.y + backupBound.height == container.getHeight() - margin.getBottom() +rc.y){ + y += difference; + } + break; + } + bounds.setLocation(x,y); + xCreator.setBackupBound(backupBound); + xCreator.setBounds(bounds); + this.fix(xCreator); } - - private void dealRight(Rectangle backupBound,int x,int w,int[] posXs,int difference,XCreator creator){ - if (backupBound.width+backupBound.x== container.getWidth() - margin.getRight()) { - return; - } - w = adjustDiffByDependingLine(x, posXs, w); - difference = w-backupBound.width; //拖拽长度 - dealDirectionAtRight(backupBound, difference, creator); + + private void dealLeft(Rectangle backupBound, int x, int[] posXs, int difference, XCreator creator) { + if (backupBound.x == margin.getLeft()) { + return; + } + x = adjustCoordinateByDependingLine(x, posXs); + difference = x - backupBound.x; + dealDirectionAtLeft(backupBound, difference, creator); } - - private void dealTop(Rectangle backupBound,int y,int[] posYs,int difference,XCreator creator){ - if (backupBound.y== margin.getTop()) { - return; - } - y = adjustCoordinateByDependingLine(y, posYs); - difference = y-backupBound.y; - dealDirectionAtTop(backupBound, difference, creator); + + private void dealRight(Rectangle backupBound, int x, int w, int[] posXs, int difference, XCreator creator) { + if (backupBound.width + backupBound.x == container.getWidth() - margin.getRight()) { + return; + } + w = adjustDiffByDependingLine(x, posXs, w); + difference = w - backupBound.width; //拖拽长度 + dealDirectionAtRight(backupBound, difference, creator); } - - private void dealButtom(Rectangle backupBound,int y,int h,int[] posYs,int difference,XCreator creator){ - if (backupBound.y+backupBound.height==container.getHeight() - margin.getBottom()) { - return; - } - h = adjustDiffByDependingLine(y, posYs, h); - difference = h-backupBound.height; - dealDirectionABottom(backupBound, difference, creator); + + private void dealTop(Rectangle backupBound, int y, int[] posYs, int difference, XCreator creator) { + if (backupBound.y == margin.getTop()) { + return; + } + y = adjustCoordinateByDependingLine(y, posYs); + difference = y - backupBound.y; + dealDirectionAtTop(backupBound, difference, creator); + } + + private void dealButtom(Rectangle backupBound, int y, int h, int[] posYs, int difference, XCreator creator) { + if (backupBound.y + backupBound.height == container.getHeight() - margin.getBottom()) { + return; + } + h = adjustDiffByDependingLine(y, posYs, h); + difference = h - backupBound.height; + dealDirectionABottom(backupBound, difference, creator); } - + // 根据需要依附的位置调整拖拽的坐标值 - private int adjustCoordinateByDependingLine(int coordinate,int[] coordinates){ - for(int i=0; i coordinates[i]-DEPENDING_SCOPE && coordinate < coordinates[i] + DEPENDING_SCOPE){ - coordinate = coordinates[i]; - break; - } - } - return coordinate; + private int adjustCoordinateByDependingLine(int coordinate, int[] coordinates) { + for (int i = 0; i < coordinates.length; i++) { + if (coordinate == coordinates[i]) { + continue; + } + if (coordinate > coordinates[i] - DEPENDING_SCOPE && coordinate < coordinates[i] + DEPENDING_SCOPE) { + coordinate = coordinates[i]; + break; + } + } + return coordinate; } - + // 根据需要依附的位置调整拖拽的距离 - private int adjustDiffByDependingLine(int coordinate,int[] coordinates,int diff){ - for(int i=0; i coordinates[i]-DEPENDING_SCOPE && coordinate+diff < coordinates[i] + DEPENDING_SCOPE){ - diff = coordinates[i] - coordinate; - break; - } - } - return diff; + private int adjustDiffByDependingLine(int coordinate, int[] coordinates, int diff) { + for (int i = 0; i < coordinates.length; i++) { + if (coordinate + diff > coordinates[i] - DEPENDING_SCOPE && coordinate + diff < coordinates[i] + DEPENDING_SCOPE) { + diff = coordinates[i] - coordinate; + break; + } + } + return diff; } - + // 左侧边框拉伸,循环找出对齐的两侧控件 private void dealDirectionAtLeft(Rectangle backupBound, int difference, Component creator) { - rightComps.add(creator); - Component rightComp = null; - int leftx = backupBound.x-DEFAULT_AREA_LENGTH - actualVal; - // 取左侧边框右面的组件x值 - int rightx = backupBound.x+DEFAULT_AREA_LENGTH; - Component leftComp = container.getLeftComp(backupBound.x, backupBound.y); - leftComps.add(leftComp); - //先找上侧对齐时(y相等)的左右两边组件 - int ry = backupBound.y; - int ly = leftComp.getY(); - int min = margin.getTop(); - int max = container.getHeight() - margin.getBottom(); - while (ry>= min && ly>= min) { - if (ry == ly) { - break; - } else { - if (ry>ly) { - rightComp = container.getTopComp(rightx, ry); - ry = rightComp.getY(); - rightComps.add(rightComp); - } else { - leftComp = container.getTopComp(leftx, ly); - ly = leftComp.getY(); - leftComps.add(leftComp); - } - } - } - // 下侧对齐时(y+h相等)两边组件 - ry = backupBound.y + backupBound.height ; - ly = leftComps.get(0).getY() + leftComps.get(0).getHeight(); - while(ry<= max && ly<= max) { - if (ry==ly) { - break; - } else { - if (ry>ly) { - leftComp = container.getComponentAt(leftx, ly+DEFAULT_AREA_LENGTH+actualVal); - ly = leftComp.getY() + leftComp.getHeight(); - leftComps.add(leftComp); - } else { - rightComp = container.getComponentAt(rightx, ry+DEFAULT_AREA_LENGTH+actualVal); - ry = rightComp.getY() + rightComp.getHeight(); - rightComps.add(rightComp); - } - } - } - dealHorDirection(backupBound.x, difference); + rightComps.add(creator); + Component rightComp = null; + int leftx = backupBound.x - DEFAULT_AREA_LENGTH - actualVal; + // 取左侧边框右面的组件x值 + int rightx = backupBound.x + DEFAULT_AREA_LENGTH; + Component leftComp = container.getLeftComp(backupBound.x, backupBound.y); + leftComps.add(leftComp); + //先找上侧对齐时(y相等)的左右两边组件 + int ry = backupBound.y; + int ly = leftComp.getY(); + int min = margin.getTop(); + int max = container.getHeight() - margin.getBottom(); + while (ry >= min && ly >= min) { + if (ry == ly) { + break; + } else { + if (ry > ly) { + rightComp = container.getTopComp(rightx, ry); + ry = rightComp.getY(); + rightComps.add(rightComp); + } else { + leftComp = container.getTopComp(leftx, ly); + ly = leftComp.getY(); + leftComps.add(leftComp); + } + } + } + // 下侧对齐时(y+h相等)两边组件 + ry = backupBound.y + backupBound.height; + ly = leftComps.get(0).getY() + leftComps.get(0).getHeight(); + while (ry <= max && ly <= max) { + if (ry == ly) { + break; + } else { + if (ry > ly) { + leftComp = container.getComponentAt(leftx, ly + DEFAULT_AREA_LENGTH + actualVal); + ly = leftComp.getY() + leftComp.getHeight(); + leftComps.add(leftComp); + } else { + rightComp = container.getComponentAt(rightx, ry + DEFAULT_AREA_LENGTH + actualVal); + ry = rightComp.getY() + rightComp.getHeight(); + rightComps.add(rightComp); + } + } + } + dealHorDirection(backupBound.x, difference); } - + // 右侧边框拉伸,循环找出对齐的两侧控件 private void dealDirectionAtRight(Rectangle backupBound, int difference, Component creator) { - leftComps.add(creator); - Component leftComp = null; - int leftx = backupBound.x+backupBound.width-DEFAULT_AREA_LENGTH; - // 取右侧边框右面的组件x值 - int rightx = backupBound.x+backupBound.width+DEFAULT_AREA_LENGTH+actualVal; - Component rightComp = container.getRightComp(backupBound.x, backupBound.y, backupBound.width); - rightComps.add(rightComp); - int ly = backupBound.y, ry = rightComp.getY(); - int min = margin.getTop(); - int max = container.getHeight() - margin.getBottom(); - while (ry>= min && ly>= min) { - if (ry == ly) { - break; - } else { - if (ry>ly) { - rightComp = container.getTopComp(rightx, ry); - ry = rightComp.getY(); - rightComps.add(rightComp); - } else { - leftComp = container.getTopComp(leftx, ly); - ly = leftComp.getY(); - leftComps.add(leftComp); - } - } - } - ly = backupBound.y + backupBound.height; - ry = rightComps.get(0).getY() + rightComps.get(0).getHeight(); - while(ry<= max && ly<= max) { - if (ry==ly) { - break; - } else { - if (ry>ly) { - leftComp = container.getComponentAt(leftx, ly+DEFAULT_AREA_LENGTH+actualVal); - ly = leftComp.getY() + leftComp.getHeight(); - leftComps.add(leftComp); - } else { - rightComp = container.getComponentAt(rightx, ry+DEFAULT_AREA_LENGTH+actualVal); - ry = rightComp.getY() + rightComp.getHeight(); - rightComps.add(rightComp); - } - } - } - dealHorDirection(backupBound.x+backupBound.width+actualVal, difference); + leftComps.add(creator); + Component leftComp = null; + int leftx = backupBound.x + backupBound.width - DEFAULT_AREA_LENGTH; + // 取右侧边框右面的组件x值 + int rightx = backupBound.x + backupBound.width + DEFAULT_AREA_LENGTH + actualVal; + Component rightComp = container.getRightComp(backupBound.x, backupBound.y, backupBound.width); + rightComps.add(rightComp); + int ly = backupBound.y, ry = rightComp.getY(); + int min = margin.getTop(); + int max = container.getHeight() - margin.getBottom(); + while (ry >= min && ly >= min) { + if (ry == ly) { + break; + } else { + if (ry > ly) { + rightComp = container.getTopComp(rightx, ry); + ry = rightComp.getY(); + rightComps.add(rightComp); + } else { + leftComp = container.getTopComp(leftx, ly); + ly = leftComp.getY(); + leftComps.add(leftComp); + } + } + } + ly = backupBound.y + backupBound.height; + ry = rightComps.get(0).getY() + rightComps.get(0).getHeight(); + while (ry <= max && ly <= max) { + if (ry == ly) { + break; + } else { + if (ry > ly) { + leftComp = container.getComponentAt(leftx, ly + DEFAULT_AREA_LENGTH + actualVal); + ly = leftComp.getY() + leftComp.getHeight(); + leftComps.add(leftComp); + } else { + rightComp = container.getComponentAt(rightx, ry + DEFAULT_AREA_LENGTH + actualVal); + ry = rightComp.getY() + rightComp.getHeight(); + rightComps.add(rightComp); + } + } + } + dealHorDirection(backupBound.x + backupBound.width + actualVal, difference); } - + /** - * 水平方向上拉伸边框的处理 + * 水平方向上拉伸边框的处理 */ private void dealHorDirection(int objx, int difference) { - if (difference>0) { - difference = Math.min(getMinWidth(rightComps)-minWidth, difference); - } else { - difference = Math.max(difference, minWidth-getMinWidth(leftComps)); - } - //重新计算左右两侧组件size、point - if(CalculateLefttRelatComponent(difference)){ - CalculateRightRelatComponent(objx+difference, -difference); - } + if (difference > 0) { + difference = Math.min(getMinWidth(rightComps) - minWidth, difference); + } else { + difference = Math.max(difference, minWidth - getMinWidth(leftComps)); + } + //重新计算左右两侧组件size、point + if (CalculateLefttRelatComponent(difference)) { + CalculateRightRelatComponent(objx + difference, -difference); + } } - + // 上侧边框拉伸,循环找出对齐的两侧控件 private void dealDirectionAtTop(Rectangle backupBound, int difference, Component creator) { - downComps.add(creator); - // 取上侧边框上面的组件用的y值 - int topy = backupBound.y-DEFAULT_AREA_LENGTH - actualVal; - // 上侧边框下面的组件y值 - int bottomy = backupBound.y+DEFAULT_AREA_LENGTH; - Component topComp = container.getTopComp(backupBound.x, backupBound.y); - upComps.add(topComp); - Component bottomComp = null; - int min = margin.getLeft(); - int max = container.getWidth() - margin.getRight(); - //先找左侧侧对齐时(x相等)的上下两边组件 - int ux = topComp.getX(); - int dx = backupBound.x; - while(ux>= min && dx>=min) { - if (ux == dx) { - break; - } else { - if (ux= min && dx >= min) { + if (ux == dx) { + break; + } else { + if (ux < dx) { + bottomComp = container.getLeftComp(dx, bottomy); + dx = bottomComp.getX(); + downComps.add(bottomComp); + } else { + topComp = container.getLeftComp(ux, topy); + ux = topComp.getX(); + upComps.add(topComp); + } + } + } + // 右侧对齐时(x+w相等)两边组件 + ux = upComps.get(0).getX() + upComps.get(0).getWidth(); + dx = backupBound.x + backupBound.width; + while (ux <= max && dx <= max) { + if (ux == dx) { + break; + } else { + if (ux < dx) { + topComp = container.getComponentAt(ux + DEFAULT_AREA_LENGTH + actualVal, topy); + ux = topComp.getX() + topComp.getWidth(); + upComps.add(topComp); + } else { + bottomComp = container.getComponentAt(dx + DEFAULT_AREA_LENGTH + actualVal, bottomy); + dx = bottomComp.getX() + bottomComp.getWidth(); + downComps.add(bottomComp); + } + } + } + + dealVertiDirection(backupBound.y, difference); } - + // 下侧边框拉伸,循环找出对齐的两侧控件 private void dealDirectionABottom(Rectangle backupBound, int difference, Component creator) { - upComps.add(creator); - Component topComp = null; - Component bottomComp = container.getBottomComp(backupBound.x, backupBound.y, backupBound.height); - // 下侧边框下面的组件y坐标 - int bottomy = backupBound.y+backupBound.height+DEFAULT_AREA_LENGTH + actualVal; - // 取下侧边框上面的组件用的y值 - int topy = backupBound.y+backupBound.height-DEFAULT_AREA_LENGTH; - downComps.add(bottomComp); - int dx = bottomComp.getX(); - int ux = backupBound.x; - int min = margin.getLeft(); - int max = container.getWidth() - margin.getRight(); - while(ux>= min && dx>= min) { - if (ux == dx) { - break; - } else { - if (ux= min && dx >= min) { + if (ux == dx) { + break; + } else { + if (ux < dx) { + bottomComp = container.getLeftComp(dx, bottomy); + dx = bottomComp.getX(); + downComps.add(bottomComp); + } else { + topComp = container.getLeftComp(ux, topy); + ux = topComp.getX(); + upComps.add(topComp); + } + } + } + dx = downComps.get(0).getX() + downComps.get(0).getWidth(); + ux = backupBound.x + backupBound.width; + while (ux <= max && dx <= max) { + if (ux == dx) { + break; + } else { + if (ux < dx) { + topComp = container.getComponentAt(ux + DEFAULT_AREA_LENGTH + actualVal, topy); + ux = topComp.getX() + topComp.getWidth(); + upComps.add(topComp); + } else { + bottomComp = container.getComponentAt(dx + DEFAULT_AREA_LENGTH + actualVal, bottomy); + dx = bottomComp.getX() + bottomComp.getWidth(); + downComps.add(bottomComp); + } + } + } + dealVertiDirection(backupBound.y + backupBound.height + actualVal, difference); } - + /** - * 垂直方向上拉伸边框的处理 + * 垂直方向上拉伸边框的处理 */ private void dealVertiDirection(int objY, int difference) { - if (difference>0) { - difference = Math.min(getMinHeight(downComps) - minHeight, difference); - } else { - difference = Math.max(difference, minHeight - getMinHeight(upComps)); - } - //重新计算上下两侧组件size、point - if(CalculateUpRelatComponent(difference)){ - CalculateDownRelatComponent(objY+difference, -difference); - }; + if (difference > 0) { + difference = Math.min(getMinHeight(downComps) - minHeight, difference); + } else { + difference = Math.max(difference, minHeight - getMinHeight(upComps)); + } + //重新计算上下两侧组件size、point + if (CalculateUpRelatComponent(difference)) { + CalculateDownRelatComponent(objY + difference, -difference); + } + ; } - + /** - * 新拖入组件时,计算调整其他关联组件位置大小 - * @param child 新拖入的组件 - * @param x 鼠标所在x坐标 - * @param y 鼠标所在y坐标 + * 新拖入组件时,计算调整其他关联组件位置大小 + * + * @param child 新拖入的组件 + * @param x 鼠标所在x坐标 + * @param y 鼠标所在y坐标 */ public 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(isCrossPointArea(parentComp, x, y)){ - //交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入 - fixCrossPointArea(parentComp, child, x, y); - return; - } else if (isTrisectionArea(parentComp, x, y)) { - // 在边界三等分区域,就不再和组件二等分了 - fixTrisect(parentComp, child, x, y); - return; - } else{ - fixHalve(parentComp, child, x, y); - } + Component parentComp = container.getComponentAt(x, y); + if (container.getComponentCount() == 0) { + child.setLocation(0, 0); + child.setSize(parentComp.getWidth(), parentComp.getHeight()); + } else if (isCrossPointArea(parentComp, x, y)) { + //交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入 + fixCrossPointArea(parentComp, child, x, y); + return; + } else if (isTrisectionArea(parentComp, x, y)) { + // 在边界三等分区域,就不再和组件二等分了 + fixTrisect(parentComp, child, x, y); + return; + } else { + fixHalve(parentComp, child, x, y); + } } - + /** * 平分,正常情况拖入组件时,按照上1/4区域、下1/4区域为上下平分,中左侧1/2区域、中右侧1/2区域为左右平分 */ protected void fixHalve(Component currentComp, XCreator child, int x, int y) { - super.fixHalve(currentComp, child, x, y); + super.fixHalve(currentComp, child, x, y); } /** @@ -654,58 +701,60 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { * 右上角和左下角是水平方向插入组件,这样避免田字块时重复 */ protected void fixCrossPointArea(Component currentComp, XCreator child, int x, int y) { - super.fixCrossPointArea(currentComp, child, x, y); + super.fixCrossPointArea(currentComp, child, x, y); } /** * 三等分区域时,调整相关联的组件 - * @param currentComp 鼠标所在组件 - * @param child 待插入组件 + * + * @param currentComp 鼠标所在组件 + * @param child 待插入组件 */ protected void fixTrisect(Component currentComp, XCreator child, int x, int y) { - super.fixTrisect(currentComp, child, x, y); + super.fixTrisect(currentComp, child, x, y); } /** - * 删除组件或者重新拖动时,其它组件重新计算位置大小 - */ - protected void delete(XCreator creator, int creatorWidth, int creatorHeight) { - int x = creator.getX(); - int y = creator.getY(); - recalculateChildrenSize(x, y, creatorWidth, creatorHeight); + * 删除组件或者重新拖动时,其它组件重新计算位置大小 + */ + protected void delete(XCreator creator, int creatorWidth, int creatorHeight) { + int x = creator.getX(); + int y = creator.getY(); + recalculateChildrenSize(x, y, creatorWidth, creatorHeight); } - + /** * 重新计算内部组件大小 - * @param x 坐标x - * @param y 坐标y - * @param creatorWidth 删除的组件之前所在布局的宽度 + * + * @param x 坐标x + * @param y 坐标y + * @param creatorWidth 删除的组件之前所在布局的宽度 * @param creatorHeight 删除的组件之前所在布局的高度 */ public void recalculateChildrenSize(int x, int y, int creatorWidth, int creatorHeight) { - if (container.getComponentCount() == 0){ - return; - } else{ - initCompsList(); - int width = creatorWidth; - int height = creatorHeight; - calculateRelatedComponent(x, y, width, height); - if (!rightComps.isEmpty() && getAllHeight(rightComps)==height){ - CalculateRightRelatComponent(x, width+actualVal); - } else if (!leftComps.isEmpty() && getAllHeight(leftComps)==height) { - CalculateLefttRelatComponent(width+actualVal); - } else if (!downComps.isEmpty() && getAllWidth(downComps)==width) { - CalculateDownRelatComponent(y, height+actualVal); - } else if(!upComps.isEmpty() && getAllWidth(upComps)==width) { - CalculateUpRelatComponent(height+actualVal); - } else { - // 由于布局三等分的存在,可能会出现删除组件时,找不到关联的组件填充,此时特殊处理 - calculateNoRelatedComponent(x, y, width, height); - } - } - clearCompsList(); + if (container.getComponentCount() == 0) { + return; + } else { + initCompsList(); + int width = creatorWidth; + int height = creatorHeight; + calculateRelatedComponent(x, y, width, height); + if (!rightComps.isEmpty() && getAllHeight(rightComps) == height) { + CalculateRightRelatComponent(x, width + actualVal); + } else if (!leftComps.isEmpty() && getAllHeight(leftComps) == height) { + CalculateLefttRelatComponent(width + actualVal); + } else if (!downComps.isEmpty() && getAllWidth(downComps) == width) { + CalculateDownRelatComponent(y, height + actualVal); + } else if (!upComps.isEmpty() && getAllWidth(upComps) == width) { + CalculateUpRelatComponent(height + actualVal); + } else { + // 由于布局三等分的存在,可能会出现删除组件时,找不到关联的组件填充,此时特殊处理 + calculateNoRelatedComponent(x, y, width, height); + } + } + clearCompsList(); } - + /** * 四侧边框都没有对齐的,此时每侧有且只有一个方向不对齐 * 比如右侧不对齐,那么必然右上或右下没对齐,不会同时不对齐,否则不会出现此情况 @@ -713,416 +762,420 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { * 右侧不对齐时的组件先上下微调,再向左侧填充。 */ private void calculateNoRelatedComponent(int x, int y, int width, int height) { - // 只有最后一个组件了,直接删除 - if (container.getComponentCount() <= 1) { - return; - } - // 删除当前组件时,由于没有刚好边框对齐的其他组件,这时候需要调整的组件 - Component rightComp = container.getRightComp(x, y, width); - if(rightComp == null){ - return; - } - - int ry = rightComp.getY(); - clearCompsList(); - initCompsList(); - Rectangle rec = new Rectangle(x, y, width, height); - if (ry != y ) { - calculateNoRelatedWhileRightTop(rec, rightComp); - } else { - calculateNoRelatedWhileRightBott(rec, rightComp); - } - + // 只有最后一个组件了,直接删除 + if (container.getComponentCount() <= 1) { + return; + } + // 删除当前组件时,由于没有刚好边框对齐的其他组件,这时候需要调整的组件 + Component rightComp = container.getRightComp(x, y, width); + if (rightComp == null) { + return; + } + + int ry = rightComp.getY(); + clearCompsList(); + initCompsList(); + Rectangle rec = new Rectangle(x, y, width, height); + if (ry != y) { + calculateNoRelatedWhileRightTop(rec, rightComp); + } else { + calculateNoRelatedWhileRightBott(rec, rightComp); + } + } - + private void calculateNoRelatedWhileRightTop(Rectangle bound, Component rcomp) { - if(rcomp == null){ - return; - } - - int ry = rcomp.getY(); - int rh = rcomp.getHeight(); - int rw = rcomp.getWidth(); - int dh = bound.y - ry - actualVal; - // 没法缩小高度 - if (dh < minHeight) { - // 没法缩小时则拉伸rcomp的上边框 - dealDirectionAtTop(rcomp.getBounds(), dh + actualVal, rcomp); - //调整的时候可能有组件达到最小高度,判断下 - if (rcomp.getY() != bound.y) { - clearCompsList(); - initCompsList(); - dealDirectionAtTop(rcomp.getBounds(), bound.y - rcomp.getY()-minHeight - actualVal, rcomp); - ry = rcomp.getY(); - int rx = rcomp.getX(); - rcomp.setBounds(rx, ry, rw, minHeight); - recalculateChildrenSize(rx, bound.y, rw, rh-dh - actualVal); - recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); - return; - } - } else { - // 右侧控件底部对齐 - if (rh+ry == bound.y+bound.height) { - rcomp.setSize(rw, dh); - bound.width += rw; - bound.width += actualVal; - } else { - recalculateChildrenSize(bound.x, ry+rh + actualVal, bound.width, bound.height+bound.y-rh-ry - actualVal); - recalculateChildrenSize(bound.x, bound.y, bound.width, ry+rh-bound.y); - return; - } - } - recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); + if (rcomp == null) { + return; + } + + int ry = rcomp.getY(); + int rh = rcomp.getHeight(); + int rw = rcomp.getWidth(); + int dh = bound.y - ry - actualVal; + // 没法缩小高度 + if (dh < minHeight) { + // 没法缩小时则拉伸rcomp的上边框 + dealDirectionAtTop(rcomp.getBounds(), dh + actualVal, rcomp); + //调整的时候可能有组件达到最小高度,判断下 + if (rcomp.getY() != bound.y) { + clearCompsList(); + initCompsList(); + dealDirectionAtTop(rcomp.getBounds(), bound.y - rcomp.getY() - minHeight - actualVal, rcomp); + ry = rcomp.getY(); + int rx = rcomp.getX(); + rcomp.setBounds(rx, ry, rw, minHeight); + recalculateChildrenSize(rx, bound.y, rw, rh - dh - actualVal); + recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); + return; + } + } else { + // 右侧控件底部对齐 + if (rh + ry == bound.y + bound.height) { + rcomp.setSize(rw, dh); + bound.width += rw; + bound.width += actualVal; + } else { + recalculateChildrenSize(bound.x, ry + rh + actualVal, bound.width, bound.height + bound.y - rh - ry - actualVal); + recalculateChildrenSize(bound.x, bound.y, bound.width, ry + rh - bound.y); + return; + } + } + recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); } - + private void calculateNoRelatedWhileRightBott(Rectangle bound, Component rcomp) { - rcomp = container.getBottomRightComp(bound.x, bound.y, bound.height, bound.width); - int ry = rcomp.getY(); - int rh = rcomp.getHeight(); - int rw = rcomp.getWidth(); - int dh = ry + rh - bound.y - bound.height - actualVal; - if (dh < minHeight) { - dealDirectionABottom(rcomp.getBounds(), -dh - actualVal, rcomp); - //调整的时候可能有组件达到最小高度,判断下 - if (rcomp.getHeight()+ry != bound.y + bound.height) { - clearCompsList(); - initCompsList(); - dh = ry + rcomp.getHeight() - bound.y - bound.height - actualVal; - dealDirectionABottom(rcomp.getBounds(), minHeight-dh, rcomp); - rh = rcomp.getHeight(); - int rx = rcomp.getX(); - rcomp.setBounds(rx, bound.y+bound.height + actualVal, rw, minHeight); - recalculateChildrenSize(rx, ry, rw, rh-minHeight - actualVal); - recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); - return; - } - } else { - if (ry == bound.y) { - rcomp.setBounds(rcomp.getX(), bound.y+bound.height + actualVal, rw, dh); - bound.width += rw; - bound.width += actualVal; - } else { - recalculateChildrenSize(bound.x, bound.y, bound.width, ry-bound.y - actualVal); - recalculateChildrenSize(bound.x, ry, bound.width, bound.height-ry+bound.y); - return; - } - } - recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); + rcomp = container.getBottomRightComp(bound.x, bound.y, bound.height, bound.width); + int ry = rcomp.getY(); + int rh = rcomp.getHeight(); + int rw = rcomp.getWidth(); + int dh = ry + rh - bound.y - bound.height - actualVal; + if (dh < minHeight) { + dealDirectionABottom(rcomp.getBounds(), -dh - actualVal, rcomp); + //调整的时候可能有组件达到最小高度,判断下 + if (rcomp.getHeight() + ry != bound.y + bound.height) { + clearCompsList(); + initCompsList(); + dh = ry + rcomp.getHeight() - bound.y - bound.height - actualVal; + dealDirectionABottom(rcomp.getBounds(), minHeight - dh, rcomp); + rh = rcomp.getHeight(); + int rx = rcomp.getX(); + rcomp.setBounds(rx, bound.y + bound.height + actualVal, rw, minHeight); + recalculateChildrenSize(rx, ry, rw, rh - minHeight - actualVal); + recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); + return; + } + } else { + if (ry == bound.y) { + rcomp.setBounds(rcomp.getX(), bound.y + bound.height + actualVal, rw, dh); + bound.width += rw; + bound.width += actualVal; + } else { + recalculateChildrenSize(bound.x, bound.y, bound.width, ry - bound.y - actualVal); + recalculateChildrenSize(bound.x, ry, bound.width, bound.height - ry + bound.y); + return; + } + } + recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height); } - + private int getMinWidth(List comps) { - if (comps.isEmpty()) { - return 0; - } - int minWidth =container.getWidth() - margin.getLeft() - margin.getRight(); - for (int i=0, size=comps.size(); icomps.get(i).getWidth() ? comps.get(i).getWidth() : minWidth; - } - return minWidth; + if (comps.isEmpty()) { + return 0; + } + int minWidth = container.getWidth() - margin.getLeft() - margin.getRight(); + for (int i = 0, size = comps.size(); i < size; i++) { + minWidth = minWidth > comps.get(i).getWidth() ? comps.get(i).getWidth() : minWidth; + } + return minWidth; } - + private int getMinHeight(List comps) { - if (comps.isEmpty()) { - return 0; - } - int minH =container.getHeight() - margin.getTop() - margin.getBottom(); - for (int i=0, size=comps.size(); icomps.get(i).getHeight() ? comps.get(i).getHeight() : minH; - } - return minH; + if (comps.isEmpty()) { + return 0; + } + int minH = container.getHeight() - margin.getTop() - margin.getBottom(); + for (int i = 0, size = comps.size(); i < size; i++) { + minH = minH > comps.get(i).getHeight() ? comps.get(i).getHeight() : minH; + } + return minH; } - + // 删除时计算待删除组件上下侧的组件是否何其对齐 private int getAllHeight(List comps) { - int allHeight = 0; - if (comps.isEmpty()) { - return allHeight; - } - int n=comps.size(); - for (int i=0; i comps) { - int allWidth = 0; - if (comps.isEmpty()) { - return allWidth; - } - int n=comps.size(); - for (int i=0; i=0 && objHeight>=(rheight+verti); - boolean isVerti = hori>=0 && objWidth>=(rwidth+hori); - if (isHori && (objX+objWidth+actualVal)==rx) { - rightComps.add(relatComp); - } else if(isHori && objX==(rx+rwidth+actualVal)) { - leftComps.add(relatComp); - } else if(isVerti && (objY+objHeight+actualVal)==ry) { - downComps.add(relatComp); - } else if(isVerti && objY==(ry+rheight+actualVal)) { - upComps.add(relatComp); - } - } + int count = container.getComponentCount(); + for (int i = 0; i < count; i++) { + Component relatComp = container.getComponent(i); + int rx = relatComp.getX(); + int ry = relatComp.getY(); + int rwidth = relatComp.getWidth(); + int rheight = relatComp.getHeight(); + int verti = ry - objY; + int hori = rx - objX; + boolean isHori = verti >= 0 && objHeight >= (rheight + verti); + boolean isVerti = hori >= 0 && objWidth >= (rwidth + hori); + if (isHori && (objX + objWidth + actualVal) == rx) { + rightComps.add(relatComp); + } else if (isHori && objX == (rx + rwidth + actualVal)) { + leftComps.add(relatComp); + } else if (isVerti && (objY + objHeight + actualVal) == ry) { + downComps.add(relatComp); + } else if (isVerti && objY == (ry + rheight + actualVal)) { + upComps.add(relatComp); + } + } } - + /** * 拖拽组件时遍历某一侧组件得到该侧组件能够缩放的最小宽度,tab布局最小宽度 = 内部组件数 * 单个组件最小宽度 + * * @param list 某一侧组件的集合 如:leftComps * @return int 最小宽度 - * */ - private int getCompsMinWidth(List list){ - return getMaxCompsNum(list, true) * WLayout.MIN_WIDTH; + private int getCompsMinWidth(List list) { + return getMaxCompsNum(list, true) * WLayout.MIN_WIDTH; } - + /** * 拖拽组件遍历某一侧得到该侧组件能够缩放的最小高度,tab布局最小高度 = 内部组件数 * 单个组件最小高度 + 标题高度 + * * @param list 某一侧组件集合 * @return int 最小高度 - * */ - private int getCompsMinHeight(List list){ - for(int i=0;i childrenList = creator.getTargetChildrenList(); - if(!childrenList.isEmpty()){ - return getMaxCompsNum(list,false) * WLayout.MIN_HEIGHT + WCardMainBorderLayout.TAB_HEIGHT; - } - } - return WLayout.MIN_HEIGHT; + private int getCompsMinHeight(List list) { + for (int i = 0; i < list.size(); i++) { + XCreator creator = (XCreator) list.get(i); + ArrayList childrenList = creator.getTargetChildrenList(); + if (!childrenList.isEmpty()) { + return getMaxCompsNum(list, false) * WLayout.MIN_HEIGHT + WCardMainBorderLayout.TAB_HEIGHT; + } + } + return WLayout.MIN_HEIGHT; } - + /** * 根据子组件的横(纵)坐标获取某一侧组件的最大内部组件数 - * @param list 某一侧组件集合 + * + * @param list 某一侧组件集合 * @param isHor 是否以横坐标为准 * @return int 最大内部组件数 - * */ - private int getMaxCompsNum(List list,boolean isHor){ - int maxCompNums = 1; - for(int i=0,size=list.size();i childrenList = creator.getTargetChildrenList(); - int count = childrenList.size(); - if(count > 0){ - for(int j=0;j list, boolean isHor) { + int maxCompNums = 1; + for (int i = 0, size = list.size(); i < size; i++) { + XCreator creator = (XCreator) list.get(i); + ArrayList childrenList = creator.getTargetChildrenList(); + int count = childrenList.size(); + if (count > 0) { + for (int j = 0; j < count; j++) { + XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList.get(j); + int[] positions = isHor ? tabLayout.getHors(true) : tabLayout.getVeris(true); + int compNums = positions.length - 1; + maxCompNums = Math.max(compNums, maxCompNums); + } + } + } + return maxCompNums; } - + /** * 根据偏移量缩放内部组件大小,(tab布局用到) + * * @param creator tab布局 - * @param offset 偏移量 - * @param isHor 是否为横向拖拽 + * @param offset 偏移量 + * @param isHor 是否为横向拖拽 */ - private void adjustCompsSize(XCreator creator,int offset,boolean isHor){ - ArrayList childrenList = creator.getTargetChildrenList(); - int size = childrenList.size(); - if(size > 0){ - for(int j=0;j childrenList = creator.getTargetChildrenList(); + int size = childrenList.size(); + if (size > 0) { + for (int j = 0; j < size; j++) { + XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList.get(j); + tabLayout.setBackupBound(tabLayout.getBounds()); + int refSize = isHor ? tabLayout.getWidth() : tabLayout.getHeight(); + double percent = (double) offset / refSize; + if (percent < 0 && !tabLayout.canReduce(percent)) { + return; + } + setAdjustedSize(tabLayout, offset, isHor); + for (int m = 0; m < tabLayout.getComponentCount(); m++) { + XCreator childCreator = tabLayout.getXCreator(m); + BoundsWidget wgt = tabLayout.toData().getBoundsWidget(childCreator.toData()); + wgt.setBounds(tabLayout.getComponent(m).getBounds()); + } + adjustCreatorsSize(percent, tabLayout, isHor); + } + + } } - + // 纵向拖拽,先将tab布局的高度设置为拖拽后的实际高度 - private void setAdjustedHeight(XWTabFitLayout tabLayout,int offset){ - tabLayout.setSize(tabLayout.getWidth(),tabLayout.getHeight() + offset); + private void setAdjustedHeight(XWTabFitLayout tabLayout, int offset) { + tabLayout.setSize(tabLayout.getWidth(), tabLayout.getHeight() + offset); } - + // 横向拖拽,先将tab布局的宽度设置为拖拽后的实际宽度 - private void setAdjustedSize(XWTabFitLayout tabLayout,int offset,boolean isHor){ - if(offset < 0){ - // 缩放时需要备份原tab布局宽高 - tabLayout.setReferDim(new Dimension(tabLayout.getWidth(),tabLayout.getHeight())); - } - if(isHor){ - tabLayout.setSize(tabLayout.getWidth() + offset, tabLayout.getHeight()); - return; - } - setAdjustedHeight(tabLayout,offset); + private void setAdjustedSize(XWTabFitLayout tabLayout, int offset, boolean isHor) { + if (offset < 0) { + // 缩放时需要备份原tab布局宽高 + tabLayout.setReferDim(new Dimension(tabLayout.getWidth(), tabLayout.getHeight())); + } + if (isHor) { + tabLayout.setSize(tabLayout.getWidth() + offset, tabLayout.getHeight()); + return; + } + setAdjustedHeight(tabLayout, offset); } - + // 按照拖拽偏移量,对tab布局进行缩放 - private void adjustCreatorsSize(double percent,XWTabFitLayout tabLayout,boolean isHor){ - if(isHor){ - tabLayout.adjustCreatorsWidth(percent); - return; - } - tabLayout.adjustCreatorsHeight(percent); + private void adjustCreatorsSize(double percent, XWTabFitLayout tabLayout, boolean isHor) { + if (isHor) { + tabLayout.adjustCreatorsWidth(percent); + return; + } + tabLayout.adjustCreatorsHeight(percent); } - - + + /** * 删除或拉伸控件右边框 调整右侧组件位置大小 - * @param objX 调整后的坐标x + * + * @param objX 调整后的坐标x * @param objWidth 调整后的宽度 */ - protected void CalculateRightRelatComponent(int objX, int objWidth){ - int count = rightComps.size(); - for(int i=0; i compsList){ - int compMinWidth = getCompsMinWidth(compsList); - for(int i=0;i (creator.getWidth() - compMinWidth)){ - return true; - } - } - return false; + private boolean isBeyondWidthScope(int offset, List compsList) { + int compMinWidth = getCompsMinWidth(compsList); + for (int i = 0; i < compsList.size(); i++) { + XCreator creator = (XCreator) compsList.get(i); + if (Math.abs(offset) > (creator.getWidth() - compMinWidth)) { + return true; + } + } + return false; } - + /** * 删除或拉伸控件左边框时 调整左侧的组件位置大小; */ - protected boolean CalculateLefttRelatComponent(int objWidth){ - if(isBeyondAdjustWidthScope(objWidth)){ - return false; - } - int count = leftComps.size(); - for(int i=0; i compsList){ - int minHeight = getCompsMinHeight(compsList); - for(int i=0;i (creator.getHeight() - minHeight)){ - return true; - } - } - return false; + private boolean isBeyondHeightScope(int offset, List compsList) { + int minHeight = getCompsMinHeight(compsList); + for (int i = 0; i < compsList.size(); i++) { + XCreator creator = (XCreator) compsList.get(i); + if (Math.abs(offset) > (creator.getHeight() - minHeight)) { + return true; + } + } + return false; } + /** * 删除或拉伸上边框 调整上方的组件位置大小 */ - protected boolean CalculateUpRelatComponent(int objHeight){ - if(isBeyondAdjustHeightScope(objHeight)){ - return false; - } - int count = upComps.size(); - for(int i=0; i 0 && ((XCreator)xCreator.getComponent(0)).shouldScaleCreator()) { - component = xCreator.getComponent(0); - component.setBounds(xCreator.getBounds()); + try { + if (state == WBodyLayoutType.ABSOLUTE.getTypeValue()) { + WAbsoluteBodyLayout wAbsoluteBodyLayout = new WAbsoluteBodyLayout("body"); + wAbsoluteBodyLayout.setCompState(WAbsoluteLayout.STATE_FIXED); + Component[] components = xfl.getComponents(); + xfl.removeAll(); + XWAbsoluteBodyLayout xwAbsoluteBodyLayout = new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0)); + xfl.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); } - xwAbsoluteBodyLayout.add(component); + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + formDesigner.getSelectionModel().setSelectedCreators( + FormSelectionUtils.rebuildSelection(xfl, new Widget[]{wAbsoluteBodyLayout})); + } else { + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + formDesigner.getSelectionModel().setSelectedCreators( + FormSelectionUtils.rebuildSelection(xfl, new Widget[]{xfl.toData()})); } - FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - formDesigner.getSelectionModel().setSelectedCreators( - FormSelectionUtils.rebuildSelection(xfl, new Widget[]{wAbsoluteBodyLayout})); - } - else { - FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - formDesigner.getSelectionModel().setSelectedCreators( - FormSelectionUtils.rebuildSelection(xfl, new Widget[]{xfl.toData()})); + }catch (Exception e){ + FRLogger.getLogger().error(e.getMessage()); + return false; } + layout.setLayoutType(WBodyLayoutType.parse(state)); return true; } return false; diff --git a/designer_form/src/com/fr/design/gui/xpane/LayoutBorderPane.java b/designer_form/src/com/fr/design/gui/xpane/LayoutBorderPane.java index d009c3e644..45713c623e 100644 --- a/designer_form/src/com/fr/design/gui/xpane/LayoutBorderPane.java +++ b/designer_form/src/com/fr/design/gui/xpane/LayoutBorderPane.java @@ -280,7 +280,7 @@ public class LayoutBorderPane extends BasicPane { Constants.LINE_THICK, //3px }; - public final static String[] BORDER_TYPE = new String[]{Inter.getLocText("FR-Designer-Widget-Style_Standard"), Inter.getLocText("FR-Designer-Widget-Style_Title")}; + public final static String[] BORDER_TYPE = new String[]{Inter.getLocText("FR-Designer-Widget-Style_Standard"), Inter.getLocText("FR-Designer-Widget-Style_Custom")}; public final static String[] BORDER_STYLE= new String[]{Inter.getLocText("FR-Designer-Widget-Style_Common"), Inter.getLocText("FR-Designer-Widget-Style_Shadow")}; private final static Dimension BUTTON_SIZE = new Dimension(24, 20); diff --git a/designer_form/src/com/fr/design/mainframe/CoverReportPane.java b/designer_form/src/com/fr/design/mainframe/CoverReportPane.java index ee1fb27bd1..1d8277c461 100644 --- a/designer_form/src/com/fr/design/mainframe/CoverReportPane.java +++ b/designer_form/src/com/fr/design/mainframe/CoverReportPane.java @@ -1,8 +1,6 @@ package com.fr.design.mainframe; import com.fr.design.constants.UIConstants; -import com.fr.design.designer.beans.events.DesignerEditListener; -import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; import com.fr.form.share.ShareConstants; @@ -13,6 +11,8 @@ import com.fr.stable.StringUtils; import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; /** * 报表块的封面(如果后面所有的组件都有帮助信息的话就抽接口吧) @@ -43,18 +43,6 @@ public class CoverReportPane extends CoverPane implements HelpDialogHandler{ public CoverReportPane(String helpMsg) { super(); this.helpMsg = helpMsg; - add(controlButton); -// if (WidgetPropertyPane.getInstance().getEditingFormDesigner() != null) { -// WidgetPropertyPane.getInstance().getEditingFormDesigner().addDesignerEditListener(new DesignerEditListener() { -// @Override -// public void fireCreatorModified(DesignerEvent evt) { -// if (evt.getCreatorEventID() == (DesignerEvent.CREATOR_DELETED) -// || evt.getCreatorEventID() == (DesignerEvent.CREATOR_RESIZED)) { -// destroyHelpDialog(); -// } -// } -// }); -// } } public String getHelpMsg() { @@ -63,12 +51,16 @@ public class CoverReportPane extends CoverPane implements HelpDialogHandler{ public void setHelpMsg(String helpMsg) { this.helpMsg = helpMsg; + //帮助信息为空就不显示帮助按钮 + if (StringUtils.isNotEmpty(helpMsg)) { + add(controlButton); + } } public void setMsgDisplay(MouseEvent e) { if (helpDialog == null) { - controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_CLOSE_ICON_PATH); - controlButton.repaint(); +// controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_CLOSE_ICON_PATH); + controlButton.setVisible(false); helpDialog = new ElementCaseHelpDialog(DesignerContext.getDesignerFrame(), helpMsg); double screenValue = FRScreen.getByDimension(Toolkit.getDefaultToolkit().getScreenSize()).getValue(); int offsetX = 0; @@ -80,12 +72,14 @@ public class CoverReportPane extends CoverPane implements HelpDialogHandler{ int rY = 165 + e.getY();//165是设计器最上面几个面板的高度 helpDialog.setLocationRelativeTo(DesignerContext.getDesignerFrame(), rX, rY); helpDialog.showWindow(); + helpDialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + helpDialog = null; + controlButton.setVisible(true); + } + }); HelpDialogManager.getInstance().setPane(this); - } else { - controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH); - controlButton.repaint(); - helpDialog.dispose(); - helpDialog = null; } } @@ -135,8 +129,8 @@ public class CoverReportPane extends CoverPane implements HelpDialogHandler{ @Override public void setVisible(boolean aFlag) { super.setVisible(aFlag); - if (aFlag) { - HelpDialogManager.getInstance().setPane(this); - } +// if (aFlag) { +// HelpDialogManager.getInstance().setPane(this); +// } } } diff --git a/designer_form/src/com/fr/design/mainframe/ElementCaseHelpDialog.java b/designer_form/src/com/fr/design/mainframe/ElementCaseHelpDialog.java index 60b699107c..2f2c6e3b5d 100644 --- a/designer_form/src/com/fr/design/mainframe/ElementCaseHelpDialog.java +++ b/designer_form/src/com/fr/design/mainframe/ElementCaseHelpDialog.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextarea.UITextArea; +import com.fr.general.Inter; import javax.swing.*; import java.awt.*; @@ -15,7 +16,7 @@ import java.awt.*; public class ElementCaseHelpDialog extends UIDialog { private static final int OUTER_WIDTH = 190; - private static final int OUTER_HEIGHT = 120; + private static final int OUTER_HEIGHT = 280; private String helpMsg; @@ -25,7 +26,6 @@ public class ElementCaseHelpDialog extends UIDialog { public ElementCaseHelpDialog(Frame parent, String helpMsg) { super(parent); this.helpMsg = helpMsg; - setUndecorated(true); initHelpArea(); JPanel panel = (JPanel) getContentPane(); initComponents(panel); @@ -37,21 +37,23 @@ public class ElementCaseHelpDialog extends UIDialog { textArea.setEditable(false); textArea.setBorder(null); helpArea = new UIScrollPane(textArea); - helpArea.setBounds(0, 0, 190, 120); + helpArea.setBounds(0, 0, OUTER_WIDTH, OUTER_HEIGHT); helpArea.setBorder(null); } private void initComponents(JPanel contentPane) { contentPane.setLayout(new BorderLayout()); add(helpArea, BorderLayout.CENTER); + this.applyClosingAction(); + this.setTitle(Inter.getLocText("FR-Designer_Help")); } /** * 打开帮助框 */ public void showWindow() { - setVisible(true); this.setResizable(false); + setVisible(true); } /**