Browse Source

Merge pull request #685 in DESIGN/design from ~KERRY/design_10.0:release/10.0 to release/10.0

* commit '0b837ebfb2ef0f8523b5db9655abccc2024b9409':
  REPORT-13626【10.0.2回归】保存模版-文件名没有实时显示搜索结果
  REPORT-13548【10.0.2回归】tab块复制粘贴后点击会产生联动
bugfix/10.0
kerry 6 years ago
parent
commit
4e1732bcad
  1. 19
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java
  2. 10
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  3. 58
      designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java

19
designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java

@ -1,11 +1,9 @@
package com.fr.design.gui.itextfield; package com.fr.design.gui.itextfield;
import com.fr.design.gui.imenu.UIListPopup; import com.fr.design.gui.imenu.UIListPopup;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.OperatingSystem; import javax.swing.JList;
import javax.swing.UIManager;
import javax.swing.*;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
@ -13,10 +11,12 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.text.AbstractDocument; import javax.swing.text.AbstractDocument;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import javax.swing.text.Document; import javax.swing.text.Document;
import java.awt.event.ActionEvent;
import java.awt.Dimension; import java.awt.event.ActionListener;
import java.awt.LayoutManager; import java.awt.event.KeyEvent;
import java.awt.event.*; import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList; import java.util.ArrayList;
public class UIAutoCompletionField extends UITextField implements DocumentListener, MouseListener, ListSelectionListener, ActionListener, KeyListener { public class UIAutoCompletionField extends UITextField implements DocumentListener, MouseListener, ListSelectionListener, ActionListener, KeyListener {
@ -82,9 +82,6 @@ public class UIAutoCompletionField extends UITextField implements DocumentListen
} }
private void textChanged() { private void textChanged() {
if (OperatingSystem.isMacOS()) {
return;
}
if (!popup.isVisible()) { if (!popup.isVisible()) {
showPopup(); showPopup();
requestFocus(); requestFocus();

10
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -106,6 +106,16 @@ public class XWCardLayout extends XLayoutContainer {
return new Dimension(500, 300); return new Dimension(500, 300);
} }
/**
* 重置组件的名称
* @param name 名称
*/
public void resetCreatorName(String name) {
super.resetCreatorName(name);
changeRelateSwitchCardName(name);
}
@Override @Override
protected void initLayoutManager() { protected void initLayoutManager() {
cardLayout = new FRCardLayout(toData().getHgap(), toData().getVgap()); cardLayout = new FRCardLayout(toData().getHgap(), toData().getVgap());

58
designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java

@ -14,12 +14,11 @@ import com.fr.design.designer.creator.XWScaleLayout;
import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.form.main.Form;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import java.awt.Component; import java.awt.Component;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
@ -97,8 +96,7 @@ public class FormSelectionUtils {
Rectangle rec = clipboard.getSelctionBounds(); Rectangle rec = clipboard.getSelctionBounds();
for (XCreator creator : clipboard.getSelectedCreators()) { for (XCreator creator : clipboard.getSelectedCreators()) {
try { try {
Widget copied = copyWidget(designer, creator); XCreator copiedCreator = copyXcreator(designer.getTarget(), creator);
XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
// 获取位置 // 获取位置
Point point = getPasteLocation((AbstractLayoutAdapter) adapter, Point point = getPasteLocation((AbstractLayoutAdapter) adapter,
copiedCreator, copiedCreator,
@ -181,8 +179,7 @@ public class FormSelectionUtils {
private static void relativePasteXCreator(FormDesigner designer, XCreator creator, LayoutAdapter adapter, Rectangle tabContainerRect, int x, int y) { private static void relativePasteXCreator(FormDesigner designer, XCreator creator, LayoutAdapter adapter, Rectangle tabContainerRect, int x, int y) {
try { try {
Widget copied = copyWidget(designer, creator); XCreator copiedXCreator = copyXcreator(designer.getTarget(), creator);
XCreator copiedXCreator = XCreatorUtils.createXCreator(copied, creator.getSize());
if (adapter.getClass().equals(FRTabFitLayoutAdapter.class)) { if (adapter.getClass().equals(FRTabFitLayoutAdapter.class)) {
if (!adapter.accept(copiedXCreator, x - tabContainerRect.x, y - tabContainerRect.y)) { if (!adapter.accept(copiedXCreator, x - tabContainerRect.x, y - tabContainerRect.y)) {
designer.showMessageDialog(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Too_Small_To_Paste")); designer.showMessageDialog(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Too_Small_To_Paste"));
@ -235,33 +232,52 @@ public class FormSelectionUtils {
return new Point(x, y); return new Point(x, y);
} }
/** /**
* 拷贝组件 * 拷贝组件
* @param form 当前表单
* @param xCreator 待拷贝的组件
* @return XCreator 拷贝的组件
*/ */
private static Widget copyWidget(FormDesigner formDesigner, XCreator xCreator) throws public static XCreator copyXcreator(Form form, XCreator xCreator) throws CloneNotSupportedException{
CloneNotSupportedException {
ArrayList<String> nameSpace = new ArrayList<>();
Widget copied = (Widget) xCreator.toData().clone(); Widget copied = (Widget) xCreator.toData().clone();
//重命名拷贝的组件 XCreator copiedCreator = XCreatorUtils.createXCreator(copied, xCreator.getSize());
String name = getCopiedName(formDesigner, copied, nameSpace); ArrayList<String> nameSpace = new ArrayList<>();
if (copied instanceof WTitleLayout) { copyWidgetName(form, nameSpace, copiedCreator);
XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) copied, xCreator.getSize()); return copiedCreator;
xwTitleLayout.resetCreatorName(name); }
} else {
copied.setWidgetName(name); /**
* 拷贝组件
* @param form 当前表单
* @param nameSpace 命名空间
* @param xCreator 拷贝的组件
*/
private static void copyWidgetName(Form form, ArrayList<String> nameSpace, XCreator xCreator){
String copyName = FormSelectionUtils.getCopiedName(form, xCreator.toData(), nameSpace);
if (xCreator.toData() instanceof WTitleLayout) {
XWTitleLayout xwTitleLayout = new XWTitleLayout((WTitleLayout) xCreator.toData(), xCreator.getSize());
xwTitleLayout.resetCreatorName(copyName);
return;
}
xCreator.resetCreatorName(copyName);
int count = xCreator.getComponentCount();
for(int a = 0; a <count; a++){
if(xCreator.getComponent(a) instanceof XCreator){
XCreator child = (XCreator)xCreator.getComponent(a);
copyWidgetName(form, nameSpace, child);
}
} }
return copied;
} }
/** /**
* 组件拷贝命名规则 * 组件拷贝命名规则
*/ */
private static String getCopiedName(FormDesigner formDesigner, Widget copied, ArrayList<String> nameSpace) { private static String getCopiedName(Form form, Widget copied, ArrayList<String> nameSpace) {
StringBuilder name = new StringBuilder(copied.getWidgetName()); StringBuilder name = new StringBuilder(copied.getWidgetName());
do { do {
name.append(POSTFIX); name.append(POSTFIX);
} while (formDesigner.getTarget().isNameExist(name.toString()) || nameSpace.contains(name.toString())); } while (form.isNameExist(name.toString()) || nameSpace.contains(name.toString()));
nameSpace.add(name.toString()); nameSpace.add(name.toString());
return name.toString(); return name.toString();
} }
@ -308,4 +324,4 @@ public class FormSelectionUtils {
} }
} }
} }
} }
Loading…
Cancel
Save