From 07ab7c7972fdb41cb3e4ceb8e4a83c47d48fec42 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 3 Nov 2016 13:56:55 +0800 Subject: [PATCH 01/19] rt --- .../src/com/fr/design/actions/AllowAuthorityEditAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java b/designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java index 5d0ccf2d09..d4e15fc13e 100644 --- a/designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java +++ b/designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java @@ -1 +1 @@ -package com.fr.design.actions; import com.fr.base.BaseUtils; import com.fr.design.constants.UIConstants; import com.fr.design.menu.KeySetUtils; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.designer.TargetComponent; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.*; /** * Author : daisy * Date: 13-8-30 * Time: 上午10:12 */ public class AllowAuthorityEditAction extends TemplateComponentAction { public AllowAuthorityEditAction(TargetComponent t) { super(t); this.setMenuKeySet(KeySetUtils.ALLOW_AUTHORITY_EDIT); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/allow_authority_edit.png")); } /** * 撤销 */ public void prepare4Undo() { HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().iniAuthorityUndoState(); } /** * 执行动作 * * @return 是否执行成功 */ public boolean executeActionReturnUndoRecordNeeded() { TargetComponent tc = getEditingComponent(); if (tc == null) { return false; } cleanAuthorityCondition(); //进入时是格式刷则取消格式刷 if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) { tc.cancelFormat(); } BaseUtils.setAuthorityEditing(true); ReportAndFSManagePane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); WestRegionContainerPane.getInstance().replaceDownPane(ReportAndFSManagePane.getInstance()); DesignerContext.getDesignerFrame().setCloseMode(UIConstants.CLOSE_OF_AUTHORITY); DesignerContext.getDesignerFrame().resetToolkitByPlus(tc.getToolBarMenuDockPlus()); DesignerContext.getDesignerFrame().needToAddAuhtorityPaint(); EastRegionContainerPane.getInstance().replaceUpPane(tc.getEastUpPane()); DesignerContext.getDesignerFrame().refreshDottedLine(); EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); //画虚线 return true; } /** * 进入权限编辑之前将权限编辑界面重置一下工具栏 */ private void cleanAuthorityCondition() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); for (int i = 0; i < opendedTemplate.size(); i++) { opendedTemplate.get(i).cleanAuthorityUndo(); } } } \ No newline at end of file +package com.fr.design.actions; import com.fr.base.BaseUtils; import com.fr.design.constants.UIConstants; import com.fr.design.menu.KeySetUtils; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.designer.TargetComponent; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.*; /** * Author : daisy * Date: 13-8-30 * Time: 上午10:12 */ public class AllowAuthorityEditAction extends TemplateComponentAction { public AllowAuthorityEditAction(TargetComponent t) { super(t); this.setMenuKeySet(KeySetUtils.ALLOW_AUTHORITY_EDIT); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/allow_authority_edit.png")); } /** * 撤销 */ public void prepare4Undo() { HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().iniAuthorityUndoState(); } /** * 执行动作 * * @return 是否执行成功 */ public boolean executeActionReturnUndoRecordNeeded() { TargetComponent tc = getEditingComponent(); if (tc == null) { return false; } cleanAuthorityCondition(); //进入时是格式刷则取消格式刷 if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) { tc.cancelFormat(); } BaseUtils.setAuthorityEditing(true); ReportAndFSManagePane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); WestRegionContainerPane.getInstance().replaceDownPane(ReportAndFSManagePane.getInstance()); DesignerContext.getDesignerFrame().setCloseMode(UIConstants.CLOSE_OF_AUTHORITY); DesignerContext.getDesignerFrame().resetToolkitByPlus(tc.getToolBarMenuDockPlus()); DesignerContext.getDesignerFrame().needToAddAuhtorityPaint(); EastRegionContainerPane.getInstance().replaceUpPane(tc.getEastUpPane()); DesignerContext.getDesignerFrame().refreshDottedLine(); EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); EastRegionContainerPane.getInstance().removeParameterPane(); //画虚线 return true; } /** * 进入权限编辑之前将权限编辑界面重置一下工具栏 */ private void cleanAuthorityCondition() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); for (int i = 0; i < opendedTemplate.size(); i++) { opendedTemplate.get(i).cleanAuthorityUndo(); } } } \ No newline at end of file From c827c18443260351aeebfdbbe5ff10466a951e31 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 4 Nov 2016 11:40:50 +0800 Subject: [PATCH 02/19] rt --- .../src/com/fr/design/mainframe/FormWidgetDetailPane.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index 6bcc9a2661..799be1b360 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -303,6 +303,7 @@ public class FormWidgetDetailPane extends FormDockView{ public void refreshDownPanel(boolean isEdit) { reuWidgetPanel.remove(downPanel); + elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList, isEdit)); reuWidgetPanel.add(downPanel); repaintContainer(); From 46199cf5a75e7386f87af53c75c5882a688b4457 Mon Sep 17 00:00:00 2001 From: richie Date: Mon, 7 Nov 2016 18:54:08 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E5=9C=A8web=E7=AB=AF=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/file/LocalePane.java | 75 +++++++------------ 1 file changed, 28 insertions(+), 47 deletions(-) diff --git a/designer_base/src/com/fr/design/actions/file/LocalePane.java b/designer_base/src/com/fr/design/actions/file/LocalePane.java index 27dad46df9..3356fa70af 100644 --- a/designer_base/src/com/fr/design/actions/file/LocalePane.java +++ b/designer_base/src/com/fr/design/actions/file/LocalePane.java @@ -8,13 +8,7 @@ import java.awt.BorderLayout; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Properties; -import java.util.Set; -import java.util.Vector; +import java.util.*; import javax.swing.JTable; import javax.swing.RowFilter; @@ -31,10 +25,7 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.dialog.BasicPane; import com.fr.file.filetree.FileNode; -import com.fr.general.FRLogger; -import com.fr.general.GeneralUtils; -import com.fr.general.IOUtils; -import com.fr.general.Inter; +import com.fr.general.*; import com.fr.stable.ArrayUtils; import com.fr.stable.project.ProjectConstants; @@ -43,12 +34,6 @@ import com.fr.stable.project.ProjectConstants; * @since : 8.0 */ public class LocalePane extends BasicPane { - private static final String FR = "fr.properties"; - private static final String US = "fr_en_US.properties"; - private static final String CN = "fr_zh_CN.properties"; - private static final String JP = "fr_ja_JP.properties"; - private static final String TW = "fr_zh_TW.properties"; - private static final String KR = "fr_ko_KR.properties"; private static final String PREFIX = "fr_"; private static final int LOCALE_NAME_LEN = 5; @@ -124,39 +109,35 @@ public class LocalePane extends BasicPane { } private void initPredefinedProperties() { - Properties fr = loadLocaleProperties(FR); - Properties us = loadLocaleProperties(US); - Properties cn = loadLocaleProperties(CN); - Properties jp = loadLocaleProperties(JP); - Properties tw = loadLocaleProperties(TW); - Properties kr = loadLocaleProperties(KR); - - Set keys = fr.stringPropertyNames(); - List sortKeys = new ArrayList(keys); + Map map = Inter.getPredefinedPackageMap(); + LocalePackage chinese = map.get(Locale.SIMPLIFIED_CHINESE); + + List sortKeys = new ArrayList(); + + + Set bundles = chinese.getKindsOfResourceBundle(); + for (ResourceBundle bundle : bundles) { + sortKeys.addAll(bundle.keySet()); + } Collections.sort(sortKeys); - Vector keyVector = new Vector(); - Vector valueVector = new Vector(); - Vector usVector = new Vector(); - Vector cnVector = new Vector(); - Vector jpVector = new Vector(); - Vector twVector = new Vector(); - Vector krVector = new Vector(); - for (String key : sortKeys) { - keyVector.add(key); - valueVector.add(fr.getProperty(key)); - usVector.add(us.getProperty(key)); - cnVector.add(cn.getProperty(key)); - jpVector.add(jp.getProperty(key)); - twVector.add(tw.getProperty(key)); - krVector.add(kr.getProperty(key)); + + Map> data = new HashMap>(); + for (Map.Entry entry : map.entrySet()) { + Vector column = new Vector(); + for (String key : sortKeys) { + column.add(entry.getValue().getLocText(key)); + } + data.put(entry.getKey(), column); } + + Vector keyVector = new Vector(); + keyVector.addAll(sortKeys); + + predefineTableModel.addColumn(Inter.getLocText("Key"), keyVector); - predefineTableModel.addColumn(Inter.getLocText("Value"), valueVector); - predefineTableModel.addColumn("en_US", usVector); - predefineTableModel.addColumn("zh_CN", cnVector); - predefineTableModel.addColumn("ja_JP", jpVector); - predefineTableModel.addColumn("zh_TW", twVector); - predefineTableModel.addColumn("ko_KR", krVector); + for (Map.Entry> entry : data.entrySet()) { + predefineTableModel.addColumn(entry.getKey().getDisplayName(), entry.getValue()); + } } private void initCustomProperties() throws Exception { From d1ba1a7e4cc9ac3fc4f8a6448fbec9a495eaf8fa Mon Sep 17 00:00:00 2001 From: Fangjie Hu Date: Tue, 8 Nov 2016 14:40:46 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E6=82=AC=E6=B5=AE=E5=85=83=E7=B4=A0?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/file/HistoryTemplateListPane.java | 3 +- .../fr/design/ChartTypeInterfaceManager.java | 54 +++++++++++-------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java index 50cdf00cf9..fff7f31224 100644 --- a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -9,8 +9,7 @@ import java.util.logging.Level; import javax.swing.*; -import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.actions.core.ActionFactory; + import com.fr.design.constants.UIConstants; import com.fr.design.DesignerEnvManager; import com.fr.design.data.DesignTableDataManager; diff --git a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java index 2af5af799b..aae009dc42 100644 --- a/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java @@ -222,16 +222,16 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh return ChartTypeManager.getInstance().containsPlot(plotID); } + /** * 把所有的pane加到list里 * * @param paneList pane容器 */ public void addPlotTypePaneList(List> paneList) { - Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); - String priority = (String) entry.getKey(); + List priorityList = getPriorityInOrder(); + for (int i = 0; i < priorityList.size(); i++){ + String priority = String.valueOf(priorityList.get(i)); Iterator chartUIIterator = chartTypeInterfaces.get(priority).entrySet().iterator(); while (chartUIIterator.hasNext()) { Map.Entry chartUIEntry = (Map.Entry) chartUIIterator.next(); @@ -276,32 +276,40 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh } private String[] getTitle4PopupWindow(){ - List priorityList = new ArrayList(); + List priorityList = getPriorityInOrder(); + + if (priorityList.size() == 0){ + return new String[0]; + } + int size = 0; - if (chartTypeInterfaces != null){ + //获取总得图表格式 + for (int i = 0; i < priorityList.size(); i++) { + size += getChartSize(String.valueOf(priorityList.get(i))); + } + String[] names = new String[size]; + + int index = 0; + for (int i = 0; i < priorityList.size(); i++){ + String priority = String.valueOf(priorityList.get(i)); + Iterator chartUI = chartTypeInterfaces.get(priority).entrySet().iterator(); + index = fetchNames(chartUI, names, index); + } + + return names; + } + + private List getPriorityInOrder() { + List priorityList = new ArrayList(); + if (chartTypeInterfaces != null) { Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()){ + while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); String priority = (String) entry.getKey(); priorityList.add(Integer.valueOf(priority)); - size += getChartSize(priority); } - String[] names = new String[size]; - - priorityList = ChartTypeManager.orderInPriority(priorityList); - - int index = 0; - - for (int i = 0; i < priorityList.size(); i++){ - String priority = String.valueOf(priorityList.get(i)); - Iterator chartUI = chartTypeInterfaces.get(priority).entrySet().iterator(); - index = fetchNames(chartUI, names, index); - } - - return names; } - - return new String[0]; + return ChartTypeManager.orderInPriority(priorityList); } private int fetchNames(Iterator chartUI, String[] names, int index) { From 92e1b01f5f0f03e74c54d8da7e25bedc0662b8bd Mon Sep 17 00:00:00 2001 From: zhouping Date: Tue, 8 Nov 2016 14:59:16 +0800 Subject: [PATCH 05/19] =?UTF-8?q?REPORT-750=20=E8=A1=A8=E5=8D=95=E5=85=B1?= =?UTF-8?q?=E5=88=9B=E5=86=85=E6=B5=8B=E9=97=AE=E9=A2=98=20bugfix3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../creator/XWAbsoluteBodyLayout.java | 39 +++++++++++++++++++ .../src/com/fr/design/mainframe/JForm.java | 3 +- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java index e4008df6f1..e41ac8cba5 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java @@ -2,9 +2,19 @@ package com.fr.design.designer.creator; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRAbsoluteBodyLayoutAdapter; +import com.fr.design.form.util.XCreatorConstants; +import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; +import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; +import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer; +import com.fr.design.mainframe.widget.renderer.PaddingMarginCellRenderer; +import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.container.WAbsoluteBodyLayout; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; +import com.fr.stable.core.PropertyChangeAdapter; import java.awt.*; +import java.beans.IntrospectionException; /** * Created by zhouping on 2016/10/14. @@ -52,4 +62,33 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { public boolean isSupportDrag() { return false; } + + /** + * 得到属性名 + * + * @return 属性名 + * @throws java.beans.IntrospectionException + */ + @Override + public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { + return new CRPropertyDescriptor[] { + new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter + .getLocText("FR-Designer_Form-Widget_Name")), + new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( + WLayoutBorderStyleEditor.class).setRendererClass(LayoutBorderStyleRenderer.class).setI18NName( + Inter.getLocText("FR-Engine_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") + .setPropertyChangeListener(new PropertyChangeAdapter() { + + @Override + public void propertyChange() { + initStyle(); + } + }) + }; + } + + @Override + protected void initStyle() { + initBorderStyle(); + } } diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index c88ebe012b..bbc1706d9b 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -657,7 +657,8 @@ public class JForm extends JTemplate implements BaseJForm { * @return 是则返回true */ public boolean isSelectRootPane() { - return formDesign.getRootComponent() == formDesign.getSelectionModel().getSelection().getSelectedCreator(); + return (formDesign.getRootComponent() == formDesign.getSelectionModel().getSelection().getSelectedCreator()) + || (formDesign.getSelectionModel().getSelection().getSelectedCreator().acceptType(XWAbsoluteBodyLayout.class)); } From 2cf1139523cbd39449550da6df337606c84afee1 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 8 Nov 2016 16:17:48 +0800 Subject: [PATCH 06/19] rt --- .../src/com/fr/design/actions/AllowAuthorityEditAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java b/designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java index d4e15fc13e..a9ac7efc28 100644 --- a/designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java +++ b/designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java @@ -1 +1 @@ -package com.fr.design.actions; import com.fr.base.BaseUtils; import com.fr.design.constants.UIConstants; import com.fr.design.menu.KeySetUtils; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.designer.TargetComponent; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.*; /** * Author : daisy * Date: 13-8-30 * Time: 上午10:12 */ public class AllowAuthorityEditAction extends TemplateComponentAction { public AllowAuthorityEditAction(TargetComponent t) { super(t); this.setMenuKeySet(KeySetUtils.ALLOW_AUTHORITY_EDIT); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/allow_authority_edit.png")); } /** * 撤销 */ public void prepare4Undo() { HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().iniAuthorityUndoState(); } /** * 执行动作 * * @return 是否执行成功 */ public boolean executeActionReturnUndoRecordNeeded() { TargetComponent tc = getEditingComponent(); if (tc == null) { return false; } cleanAuthorityCondition(); //进入时是格式刷则取消格式刷 if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) { tc.cancelFormat(); } BaseUtils.setAuthorityEditing(true); ReportAndFSManagePane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); WestRegionContainerPane.getInstance().replaceDownPane(ReportAndFSManagePane.getInstance()); DesignerContext.getDesignerFrame().setCloseMode(UIConstants.CLOSE_OF_AUTHORITY); DesignerContext.getDesignerFrame().resetToolkitByPlus(tc.getToolBarMenuDockPlus()); DesignerContext.getDesignerFrame().needToAddAuhtorityPaint(); EastRegionContainerPane.getInstance().replaceUpPane(tc.getEastUpPane()); DesignerContext.getDesignerFrame().refreshDottedLine(); EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); EastRegionContainerPane.getInstance().removeParameterPane(); //画虚线 return true; } /** * 进入权限编辑之前将权限编辑界面重置一下工具栏 */ private void cleanAuthorityCondition() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); for (int i = 0; i < opendedTemplate.size(); i++) { opendedTemplate.get(i).cleanAuthorityUndo(); } } } \ No newline at end of file +package com.fr.design.actions; import com.fr.base.BaseUtils; import com.fr.design.constants.UIConstants; import com.fr.design.menu.KeySetUtils; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.designer.TargetComponent; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.*; /** * Author : daisy * Date: 13-8-30 * Time: 上午10:12 */ public class AllowAuthorityEditAction extends TemplateComponentAction { public AllowAuthorityEditAction(TargetComponent t) { super(t); this.setMenuKeySet(KeySetUtils.ALLOW_AUTHORITY_EDIT); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/allow_authority_edit.png")); } /** * 撤销 */ public void prepare4Undo() { HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().iniAuthorityUndoState(); } /** * 执行动作 * * @return 是否执行成功 */ public boolean executeActionReturnUndoRecordNeeded() { TargetComponent tc = getEditingComponent(); if (tc == null) { return false; } cleanAuthorityCondition(); //进入时是格式刷则取消格式刷 if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) { tc.cancelFormat(); } BaseUtils.setAuthorityEditing(true); ReportAndFSManagePane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); WestRegionContainerPane.getInstance().replaceDownPane(ReportAndFSManagePane.getInstance()); DesignerContext.getDesignerFrame().setCloseMode(UIConstants.CLOSE_OF_AUTHORITY); DesignerContext.getDesignerFrame().resetToolkitByPlus(tc.getToolBarMenuDockPlus()); DesignerContext.getDesignerFrame().needToAddAuhtorityPaint(); EastRegionContainerPane.getInstance().replaceUpPane(tc.getEastUpPane()); DesignerContext.getDesignerFrame().refreshDottedLine(); EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); EastRegionContainerPane.getInstance().removeParameterPane(); //画虚线 return true; } /** * 进入权限编辑之前将权限编辑界面重置一下工具栏 */ private void cleanAuthorityCondition() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); for (int i = 0; i < opendedTemplate.size(); i++) { opendedTemplate.get(i).cleanAuthorityUndo(); } } } \ No newline at end of file From 68226c50bcd911a22f5bc6341feffa7dfb3b001d Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 8 Nov 2016 16:19:48 +0800 Subject: [PATCH 07/19] rt --- .../src/com/fr/design/mainframe/FormDesigner.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormDesigner.java b/designer_form/src/com/fr/design/mainframe/FormDesigner.java index fffccd3fff..465b6588c5 100644 --- a/designer_form/src/com/fr/design/mainframe/FormDesigner.java +++ b/designer_form/src/com/fr/design/mainframe/FormDesigner.java @@ -198,13 +198,7 @@ public class FormDesigner extends TargetComponent
implements TreeSelection ParameterPropertyPane.getInstance().getParameterToolbarPane().populateBean( getParameterArray() == null ? new Parameter[0] : getParameterArray()); ParameterPropertyPane.getInstance().repaintContainer(); - if (getParameterArray().length == 0) { - EastRegionContainerPane.getInstance().setParameterHeight(30); - } else { - //参数面板独立后只能这边触发调整高度,根据参数个数调整换行,计算高度 - EastRegionContainerPane.getInstance().setParameterHeight((getParameterArray().length + 5) / 6 * 30 + 80); - } - + EastRegionContainerPane.getInstance().setParameterHeight(ParameterPropertyPane.getInstance().getPreferredSize().height); } private void removeSame(Parameter[] parameters, List namelist){ From a165e869ba25b6b242df1d783775e7fadfeea389 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 8 Nov 2016 16:20:13 +0800 Subject: [PATCH 08/19] rt --- .../com/fr/design/form/parameter/FormParaDesigner.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java b/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java index c97e0b7235..211d5e6c18 100644 --- a/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java @@ -230,14 +230,9 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP } ParameterPropertyPane.getInstance().getParameterToolbarPane().populateBean( p.getParameterArray() == null ? new Parameter[0] : p.getParameterArray()); - EastRegionContainerPane.getInstance().addParameterPane(ParameterPropertyPane.getInstance(this)); - if (p.getParameterArray().length == 0) { - EastRegionContainerPane.getInstance().setParameterHeight(30); - } else { - //参数面板独立后只能这边触发调整高度,根据参数个数调整换行,计算高度 - EastRegionContainerPane.getInstance().setParameterHeight((p.getParameterArray().length + 5) / 6 * 30 + 80); - } + EastRegionContainerPane.getInstance().setParameterHeight(ParameterPropertyPane.getInstance().getPreferredSize().height); + } /** From 7f63787080fcc2152eee0eece6adec33f1041aca Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 8 Nov 2016 16:20:41 +0800 Subject: [PATCH 09/19] rt --- .../src/com/fr/design/actions/AllowAuthorityEditAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java b/designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java index a9ac7efc28..4a79a2d986 100644 --- a/designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java +++ b/designer_base/src/com/fr/design/actions/AllowAuthorityEditAction.java @@ -1 +1 @@ -package com.fr.design.actions; import com.fr.base.BaseUtils; import com.fr.design.constants.UIConstants; import com.fr.design.menu.KeySetUtils; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.designer.TargetComponent; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.*; /** * Author : daisy * Date: 13-8-30 * Time: 上午10:12 */ public class AllowAuthorityEditAction extends TemplateComponentAction { public AllowAuthorityEditAction(TargetComponent t) { super(t); this.setMenuKeySet(KeySetUtils.ALLOW_AUTHORITY_EDIT); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/allow_authority_edit.png")); } /** * 撤销 */ public void prepare4Undo() { HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().iniAuthorityUndoState(); } /** * 执行动作 * * @return 是否执行成功 */ public boolean executeActionReturnUndoRecordNeeded() { TargetComponent tc = getEditingComponent(); if (tc == null) { return false; } cleanAuthorityCondition(); //进入时是格式刷则取消格式刷 if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) { tc.cancelFormat(); } BaseUtils.setAuthorityEditing(true); ReportAndFSManagePane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); WestRegionContainerPane.getInstance().replaceDownPane(ReportAndFSManagePane.getInstance()); DesignerContext.getDesignerFrame().setCloseMode(UIConstants.CLOSE_OF_AUTHORITY); DesignerContext.getDesignerFrame().resetToolkitByPlus(tc.getToolBarMenuDockPlus()); DesignerContext.getDesignerFrame().needToAddAuhtorityPaint(); EastRegionContainerPane.getInstance().replaceUpPane(tc.getEastUpPane()); DesignerContext.getDesignerFrame().refreshDottedLine(); EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); EastRegionContainerPane.getInstance().removeParameterPane(); //画虚线 return true; } /** * 进入权限编辑之前将权限编辑界面重置一下工具栏 */ private void cleanAuthorityCondition() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); for (int i = 0; i < opendedTemplate.size(); i++) { opendedTemplate.get(i).cleanAuthorityUndo(); } } } \ No newline at end of file +package com.fr.design.actions; import com.fr.base.BaseUtils; import com.fr.design.constants.UIConstants; import com.fr.design.menu.KeySetUtils; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.designer.TargetComponent; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.*; /** * Author : daisy * Date: 13-8-30 * Time: 上午10:12 */ public class AllowAuthorityEditAction extends TemplateComponentAction { public AllowAuthorityEditAction(TargetComponent t) { super(t); this.setMenuKeySet(KeySetUtils.ALLOW_AUTHORITY_EDIT); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/allow_authority_edit.png")); } /** * 撤销 */ public void prepare4Undo() { HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().iniAuthorityUndoState(); } /** * 执行动作 * * @return 是否执行成功 */ public boolean executeActionReturnUndoRecordNeeded() { TargetComponent tc = getEditingComponent(); if (tc == null) { return false; } cleanAuthorityCondition(); //进入时是格式刷则取消格式刷 if (DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL) { tc.cancelFormat(); } BaseUtils.setAuthorityEditing(true); ReportAndFSManagePane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); WestRegionContainerPane.getInstance().replaceDownPane(ReportAndFSManagePane.getInstance()); DesignerContext.getDesignerFrame().setCloseMode(UIConstants.CLOSE_OF_AUTHORITY); DesignerContext.getDesignerFrame().resetToolkitByPlus(tc.getToolBarMenuDockPlus()); DesignerContext.getDesignerFrame().needToAddAuhtorityPaint(); EastRegionContainerPane.getInstance().replaceUpPane(tc.getEastUpPane()); DesignerContext.getDesignerFrame().refreshDottedLine(); EastRegionContainerPane.getInstance().replaceDownPane(RolesAlreadyEditedPane.getInstance()); EastRegionContainerPane.getInstance().removeParameterPane(); //画虚线 return true; } /** * 进入权限编辑之前将权限编辑界面重置一下工具栏 */ private void cleanAuthorityCondition() { java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); for (int i = 0; i < opendedTemplate.size(); i++) { opendedTemplate.get(i).cleanAuthorityUndo(); } } } \ No newline at end of file From 52883ba4d144a655619da68ebfcb353771b1efb1 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 8 Nov 2016 16:48:07 +0800 Subject: [PATCH 10/19] rt --- .../src/com/fr/design/parameter/ParameterPropertyPane.java | 4 ++-- .../src/com/fr/design/parameter/ParameterToolBarPane.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/designer_form/src/com/fr/design/parameter/ParameterPropertyPane.java b/designer_form/src/com/fr/design/parameter/ParameterPropertyPane.java index f376bd6ab8..f093a14327 100644 --- a/designer_form/src/com/fr/design/parameter/ParameterPropertyPane.java +++ b/designer_form/src/com/fr/design/parameter/ParameterPropertyPane.java @@ -45,9 +45,9 @@ public class ParameterPropertyPane extends JPanel{ toolbarPane = new ParameterToolBarPane(); initParameterListener(); - + this.setLayout(new BorderLayout(0, 6)); - this.setBorder(BorderFactory.createEmptyBorder(2, 5, 5, 5)); + this.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); this.add(toolbarPane, BorderLayout.CENTER); } diff --git a/designer_form/src/com/fr/design/parameter/ParameterToolBarPane.java b/designer_form/src/com/fr/design/parameter/ParameterToolBarPane.java index d495e9c06a..4d6eb655f6 100644 --- a/designer_form/src/com/fr/design/parameter/ParameterToolBarPane.java +++ b/designer_form/src/com/fr/design/parameter/ParameterToolBarPane.java @@ -35,6 +35,7 @@ public class ParameterToolBarPane extends BasicBeanPane { private static final int GAP_BV = 4; private static final int L_H = 18; + private static int HEIGHT = 0; public ParameterToolBarPane() { this.setLayout(new FlowParameterPaneLayout()); From 379fb70e4315cf52c3e0cab859960ff66dc9788c Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 8 Nov 2016 16:51:01 +0800 Subject: [PATCH 11/19] rt --- .../src/com/fr/design/mainframe/FormHierarchyTreePane.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java b/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java index 91f92cba69..5bfbfa6304 100644 --- a/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java +++ b/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java @@ -79,7 +79,7 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree this.componentTree = null; // this.searchTextField = null; // this.searchResult = null; - add(new JScrollPane(), BorderLayout.CENTER); +// add(new JScrollPane(), BorderLayout.CENTER); } @Override @@ -109,7 +109,7 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree adjustPosition(treeModel, formDesigner); } JPanel widgetPane = new JPanel(); - widgetPane.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0)); + widgetPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); widgetPane.setLayout(FRGUIPaneFactory.createBorderLayout()); add(widgetPane, BorderLayout.NORTH); widgetPane.add(new UILabel(Inter.getLocText("FR-Designer-Selected_Widget") + " ", From 2c9a6ee822da75529514042a8a176ceded6d6abf Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 8 Nov 2016 16:51:30 +0800 Subject: [PATCH 12/19] rt --- .../src/com/fr/design/form/parameter/FormParaDesigner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java b/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java index 211d5e6c18..f283904be3 100644 --- a/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer_form/src/com/fr/design/form/parameter/FormParaDesigner.java @@ -231,7 +231,7 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP ParameterPropertyPane.getInstance().getParameterToolbarPane().populateBean( p.getParameterArray() == null ? new Parameter[0] : p.getParameterArray()); EastRegionContainerPane.getInstance().addParameterPane(ParameterPropertyPane.getInstance(this)); - EastRegionContainerPane.getInstance().setParameterHeight(ParameterPropertyPane.getInstance().getPreferredSize().height); + EastRegionContainerPane.getInstance().setParameterHeight(ParameterPropertyPane.getInstance(this).getPreferredSize().height); } From 9b8816f1e238ecf46292b7628c81d298aa34a84e Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 8 Nov 2016 16:52:02 +0800 Subject: [PATCH 13/19] rt --- designer_form/src/com/fr/design/mainframe/FormDesigner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormDesigner.java b/designer_form/src/com/fr/design/mainframe/FormDesigner.java index 465b6588c5..8422bfdb40 100644 --- a/designer_form/src/com/fr/design/mainframe/FormDesigner.java +++ b/designer_form/src/com/fr/design/mainframe/FormDesigner.java @@ -198,7 +198,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection ParameterPropertyPane.getInstance().getParameterToolbarPane().populateBean( getParameterArray() == null ? new Parameter[0] : getParameterArray()); ParameterPropertyPane.getInstance().repaintContainer(); - EastRegionContainerPane.getInstance().setParameterHeight(ParameterPropertyPane.getInstance().getPreferredSize().height); + EastRegionContainerPane.getInstance().setParameterHeight(ParameterPropertyPane.getInstance(this).getPreferredSize().height); } private void removeSame(Parameter[] parameters, List namelist){ From b3bcd7085aac492d375f9c201cf695b02592b9e8 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 8 Nov 2016 17:17:40 +0800 Subject: [PATCH 14/19] rt --- .../gui/icontainer/UIResizableContainer.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/icontainer/UIResizableContainer.java b/designer_base/src/com/fr/design/gui/icontainer/UIResizableContainer.java index 201aee7594..d69a54dce5 100644 --- a/designer_base/src/com/fr/design/gui/icontainer/UIResizableContainer.java +++ b/designer_base/src/com/fr/design/gui/icontainer/UIResizableContainer.java @@ -222,7 +222,11 @@ public class UIResizableContainer extends JPanel { toolPaneY = getHeight() - toolPaneHeight; } parameterPane.setBounds(20, 0, 230, getParameterPaneHeight()); + + + upPane.setBounds(toolPaneHeight, getParameterPaneHeight(), containerWidth - toolPaneHeight, toolPaneY); + horizontToolPane.setBounds(toolPaneHeight, toolPaneY + getParameterPaneHeight(), containerWidth - toolPaneHeight, toolPaneHeight); downPane.setBounds(toolPaneHeight, toolPaneY + toolPaneHeight + getParameterPaneHeight(), containerWidth - toolPaneHeight, parent.getHeight() - toolPaneY - toolPaneHeight - getParameterPaneHeight()); verticalToolPane.setBounds(0, 0, toolPaneHeight, getHeight()); @@ -232,7 +236,6 @@ public class UIResizableContainer extends JPanel { verticalToolPane.setBounds(0, 0, toolPaneHeight, getHeight()); } } - } @Override @@ -302,6 +305,15 @@ public class UIResizableContainer extends JPanel { return this.downPane; } + /** + * 得到参数面板 + * + * @return + */ + public JComponent getParameterPane() { + return this.parameterPane; + } + /** * 刷新下面板 */ @@ -343,7 +355,7 @@ public class UIResizableContainer extends JPanel { public void mouseDragged(MouseEvent e) { toolPaneY = e.getYOnScreen() - UIResizableContainer.this.getLocationOnScreen().y; toolPaneY = toolPaneY < 0 ? 0 : toolPaneY; - toolPaneY = toolPaneY > UIResizableContainer.this.getHeight() - toolPaneHeight ? UIResizableContainer.this.getHeight() - toolPaneHeight : toolPaneY; + toolPaneY = toolPaneY > UIResizableContainer.this.getHeight() - toolPaneHeight ? UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight() : toolPaneY - getParameterPaneHeight(); refreshContainer(); } }); @@ -366,7 +378,7 @@ public class UIResizableContainer extends JPanel { if (e.getX() <= ARROW_RANGE) { toolPaneY = 0; } else if (e.getX() >= getWidth() - ARROW_RANGE) { - toolPaneY = UIResizableContainer.this.getHeight() - toolPaneHeight; + toolPaneY = UIResizableContainer.this.getHeight() - toolPaneHeight - getParameterPaneHeight(); } else { return; } From 60fd977db6ac82fc60881e3ad4fb2f97372317e1 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 8 Nov 2016 17:29:58 +0800 Subject: [PATCH 15/19] rt --- .../src/com/fr/design/parameter/ParameterToolBarPane.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer_form/src/com/fr/design/parameter/ParameterToolBarPane.java b/designer_form/src/com/fr/design/parameter/ParameterToolBarPane.java index 4d6eb655f6..d495e9c06a 100644 --- a/designer_form/src/com/fr/design/parameter/ParameterToolBarPane.java +++ b/designer_form/src/com/fr/design/parameter/ParameterToolBarPane.java @@ -35,7 +35,6 @@ public class ParameterToolBarPane extends BasicBeanPane { private static final int GAP_BV = 4; private static final int L_H = 18; - private static int HEIGHT = 0; public ParameterToolBarPane() { this.setLayout(new FlowParameterPaneLayout()); From 1f3349d70826fd8264feb5cd4bc0dc538e385342 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 8 Nov 2016 17:32:57 +0800 Subject: [PATCH 16/19] rt --- .../src/com/fr/design/mainframe/FormWidgetDetailPane.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index 0de3b27386..a1fb5f1476 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -315,7 +315,6 @@ public class FormWidgetDetailPane extends FormDockView{ public void refreshDownPanel(boolean isEdit) { reuWidgetPanel.remove(downPanel); - elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList, isEdit)); reuWidgetPanel.add(downPanel); repaintContainer(); From 40a36cac8f62c0f279442803475bf606b4949ef9 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 8 Nov 2016 17:38:35 +0800 Subject: [PATCH 17/19] rt --- .../com/fr/design/gui/icontainer/UIResizableContainer.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/icontainer/UIResizableContainer.java b/designer_base/src/com/fr/design/gui/icontainer/UIResizableContainer.java index d69a54dce5..86945674bf 100644 --- a/designer_base/src/com/fr/design/gui/icontainer/UIResizableContainer.java +++ b/designer_base/src/com/fr/design/gui/icontainer/UIResizableContainer.java @@ -222,11 +222,7 @@ public class UIResizableContainer extends JPanel { toolPaneY = getHeight() - toolPaneHeight; } parameterPane.setBounds(20, 0, 230, getParameterPaneHeight()); - - - upPane.setBounds(toolPaneHeight, getParameterPaneHeight(), containerWidth - toolPaneHeight, toolPaneY); - horizontToolPane.setBounds(toolPaneHeight, toolPaneY + getParameterPaneHeight(), containerWidth - toolPaneHeight, toolPaneHeight); downPane.setBounds(toolPaneHeight, toolPaneY + toolPaneHeight + getParameterPaneHeight(), containerWidth - toolPaneHeight, parent.getHeight() - toolPaneY - toolPaneHeight - getParameterPaneHeight()); verticalToolPane.setBounds(0, 0, toolPaneHeight, getHeight()); From e537b799f3951a7dd55517c75ff9362ca345254f Mon Sep 17 00:00:00 2001 From: zhouping Date: Wed, 9 Nov 2016 15:11:03 +0800 Subject: [PATCH 18/19] =?UTF-8?q?REPORT-750=20=E8=A1=A8=E5=8D=95=E5=85=B1?= =?UTF-8?q?=E5=88=9B=E5=86=85=E6=B5=8B=E9=97=AE=E9=A2=98=20bugfix4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/FRAbsoluteLayoutAdapter.java | 10 +- ...bsoluteBodyLayoutPropertiesGroupModel.java | 94 +++++++++++-------- .../FRFitLayoutPropertiesGroupModel.java | 53 ++++++----- 3 files changed, 89 insertions(+), 68 deletions(-) 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/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java index 6b29a172e5..b290bcccfb 100644 --- a/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java +++ b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java @@ -9,6 +9,7 @@ import com.fr.design.mainframe.widget.editors.LayoutTypeEditor; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WBodyLayoutType; +import com.fr.general.FRLogger; import com.fr.general.FRScreen; import com.fr.general.Inter; @@ -92,46 +93,7 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr } else { if (row == 0) { if (state == WBodyLayoutType.FIT.getTypeValue()) { - XWFitLayout xfl = (XWFitLayout) xwAbsoluteLayout.getBackupParent(); - //备份一下组件间隔 - int compInterval = xfl.toData().getCompInterval(); - Component[] components = xwAbsoluteLayout.getComponents(); - - Arrays.sort(components, new ComparatorComponentLocation()); - - xfl.getLayoutAdapter().removeBean(xwAbsoluteLayout, xwAbsoluteLayout.getWidth(), xwAbsoluteLayout.getHeight()); - xfl.remove(xwAbsoluteLayout); - - for (Component comp : components) { - XCreator xCreator = (XCreator)comp; - if (xCreator.shouldScaleCreator()){ - XLayoutContainer parentPanel = xCreator.initCreatorWrapper(xCreator.getHeight()); - xfl.add(parentPanel, xCreator.toData().getWidgetName()); - parentPanel.updateChildBound(xfl.getActualMinHeight()); - continue; - } - xfl.add(xCreator); - } - //这边计算的时候会先把组件间隔去掉 - moveComponents2FitLayout(xfl); - FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - formDesigner.getSelectionModel().setSelectedCreator(xfl); - - for (int i = 0; i < components.length; i++) { - Component comp = xfl.getComponent(i); - XCreator creator = (XCreator) comp; - creator.setBackupBound(components[i].getBounds()); - } - - //把组件间隔加上 - if (xfl.toData().getCompInterval() != compInterval) { - xfl.moveContainerMargin(); - xfl.moveCompInterval(xfl.getAcualInterval()); - xfl.toData().setCompInterval(compInterval); - xfl.addCompInterval(xfl.getAcualInterval()); - } - xfl.toData().setLayoutType(WBodyLayoutType.FIT); - return true; + return switch2FitBodyLayout(); } } if (row == 1) { @@ -166,7 +128,57 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr return true; } - //把绝对布局中的元素按规则移动到自适应布局中 + private boolean switch2FitBodyLayout() { + try { + XWFitLayout xfl = (XWFitLayout) xwAbsoluteLayout.getBackupParent(); + //备份一下组件间隔 + int compInterval = xfl.toData().getCompInterval(); + Component[] components = xwAbsoluteLayout.getComponents(); + + Arrays.sort(components, new ComparatorComponentLocation()); + + xfl.getLayoutAdapter().removeBean(xwAbsoluteLayout, xwAbsoluteLayout.getWidth(), xwAbsoluteLayout.getHeight()); + xfl.remove(xwAbsoluteLayout); + + for (Component comp : components) { + XCreator xCreator = (XCreator) comp; + if (xCreator.shouldScaleCreator()) { + XLayoutContainer parentPanel = xCreator.initCreatorWrapper(xCreator.getHeight()); + xfl.add(parentPanel, xCreator.toData().getWidgetName()); + parentPanel.updateChildBound(xfl.getActualMinHeight()); + continue; + } + xfl.add(xCreator); + } + //这边计算的时候会先把组件间隔去掉 + moveComponents2FitLayout(xfl); + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + formDesigner.getSelectionModel().setSelectedCreator(xfl); + + for (int i = 0; i < components.length; i++) { + Component comp = xfl.getComponent(i); + XCreator creator = (XCreator) comp; + creator.setBackupBound(components[i].getBounds()); + } + + //把组件间隔加上 + if (xfl.toData().getCompInterval() != compInterval) { + xfl.moveContainerMargin(); + xfl.moveCompInterval(xfl.getAcualInterval()); + xfl.toData().setCompInterval(compInterval); + xfl.addCompInterval(xfl.getAcualInterval()); + } + xfl.toData().setLayoutType(WBodyLayoutType.FIT); + return true; + } + catch (Exception e){ + FRLogger.getLogger().error(e.getMessage()); + return false; + } + } + + // 把绝对布局中的元素按规则移动到自适应布局中 + // 规则:各元素按顺序放置,其中每行最多4个元素,超出则换行,各元素均分body的高度和宽度 private void moveComponents2FitLayout(XWFitLayout xwFitLayout) { int eachRowCount = 4; Component[] components = xwFitLayout.getComponents(); diff --git a/designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java b/designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java index c9654e26d0..9ffad45338 100644 --- a/designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java +++ b/designer_form/src/com/fr/design/designer/properties/FRFitLayoutPropertiesGroupModel.java @@ -17,6 +17,7 @@ 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.FRLogger; import com.fr.general.Inter; import javax.swing.table.DefaultTableCellRenderer; @@ -145,34 +146,38 @@ public class FRFitLayoutPropertiesGroupModel implements GroupModel { layout.setCompState(state); return true; }else if (row == 0) { - layout.setLayoutType(WBodyLayoutType.parse(state)); - 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()); + 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; From fbbaab5055cad14d5c3a681d011d7a7b5bceb3e2 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 9 Nov 2016 15:32:20 +0800 Subject: [PATCH 19/19] =?UTF-8?q?REPORT-578=20=E8=A1=A8=E5=8D=95=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E6=A0=B7=E5=BC=8F=E5=B1=9E=E6=80=A7=E5=B0=8F=E6=94=B9?= =?UTF-8?q?=E8=89=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapters/layout/FRFitLayoutAdapter.java | 1825 +++++++++-------- .../design/designer/creator/XChartEditor.java | 2 +- .../designer/creator/XLayoutContainer.java | 4 +- .../creator/cardlayout/XWCardLayout.java | 2 +- .../creator/cardlayout/XWTabFitLayout.java | 2 +- .../properties/FRFitLayoutConstraints.java | 42 +- .../fr/design/gui/xpane/LayoutBorderPane.java | 2 +- 7 files changed, 983 insertions(+), 896 deletions(-) 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