Browse Source

表单交互统一测试bug修改

1.从toolbarbtn上拖下tab布局后当前的选中对象并非顶层布局
2.tab布局顶层布局的名字修改为tablayout
3.支持tab布局的嵌套后正确显示编辑层
master
zhouping 9 years ago
parent
commit
3f4465ff1d
  1. 3
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  2. 9
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  3. 50
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java
  4. 7
      designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java

3
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -219,8 +219,7 @@ public class XWCardLayout extends XLayoutContainer {
* *
*/ */
protected void setWrapperName(XLayoutContainer parentPanel, String widgetName) { protected void setWrapperName(XLayoutContainer parentPanel, String widgetName) {
//先随便set一个, 以后还是要隐藏的 parentPanel.toData().setWidgetName("tablayout" + widgetName.replaceAll(createDefaultName(),""));
parentPanel.toData().setWidgetName("border_card_" + widgetName);
} }
/** /**

9
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -11,6 +11,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
@ -263,6 +264,12 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
*/ */
@Override @Override
public XLayoutContainer getTopLayout() { public XLayoutContainer getTopLayout() {
return this; XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout();
if (xTopLayout != null && !xTopLayout.isEditable()){
return xTopLayout;
}
else{
return this;
}
} }
} }

50
designer_form/src/com/fr/design/mainframe/EditingMouseListener.java

@ -1,9 +1,6 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import java.awt.Color; import java.awt.*;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Rectangle;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import javax.swing.*; import javax.swing.*;
@ -326,10 +323,12 @@ public class EditingMouseListener extends MouseInputAdapter {
if (designer.getCursor().getType() == Cursor.HAND_CURSOR) { if (designer.getCursor().getType() == Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} }
if (e.getX() > (parent.getX() + parent.getWidth() / 2 - EDIT_BTN_WIDTH / 2 - GAP) int minX = getParentPositionX(parent, parent.getX()) + parent.getWidth() / 2;
&& e.getX() < (parent.getX() + parent.getWidth() / 2 + EDIT_BTN_WIDTH / 2 + GAP)) { int minY = getParentPositionY(parent, parent.getY()) + parent.getHeight() / 2;
if (e.getY() > (parent.getY() + parent.getHeight() / 2 - EDIT_BTN_HEIGHT / 2 - GAP) int offsetX = EDIT_BTN_WIDTH / 2 + GAP;
&& e.getY() < (parent.getY() + parent.getHeight() / 2 + EDIT_BTN_HEIGHT / 2 + GAP + designer.getParaHeight())) { int offsetY = EDIT_BTN_HEIGHT / 2 + GAP;
if (e.getX() > (minX - offsetX) && e.getX() < (minX + offsetX)) {
if (e.getY() > (minY - offsetY) && e.getY() < (minY + offsetY + designer.getParaHeight())) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
} }
} }
@ -417,11 +416,43 @@ public class EditingMouseListener extends MouseInputAdapter {
designer.repaint(); designer.repaint();
} }
//当前编辑的组件是在布局中,鼠标点击布局外部,需要一次性将布局及其父布局都置为不可编辑
private void setTopLayoutUnEditable(XLayoutContainer clickedTopLayout, XLayoutContainer clickingTopLayout){
//双击的前后点击click为相同对象,过滤掉
if (clickedTopLayout == null || clickedTopLayout == clickingTopLayout){
return;
}
//位于同一层级的控件,父布局相同,过滤掉
if (clickingTopLayout != null && clickedTopLayout.getParent() == clickingTopLayout.getParent()){
return;
}
//前后点击的位于不同层级,要置为不可编辑
XLayoutContainer xLayoutContainer = (XLayoutContainer)clickedTopLayout.getParent();
if (xLayoutContainer == clickingTopLayout){
return;
}
if (xLayoutContainer != null){
xLayoutContainer.setEditable(false);
setTopLayoutUnEditable((XLayoutContainer) clickedTopLayout.getParent(), clickingTopLayout);
}
}
private boolean isCreatorInLayout(XCreator creator, XCreator layout){
if (creator == layout){
return true;
}
if(layout.getParent() != null){
return isCreatorInLayout(creator, (XCreator)layout.getParent());
}
return false;
}
private XCreator processTopLayoutMouseClick(XCreator creator){ private XCreator processTopLayoutMouseClick(XCreator creator){
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout(); XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout();
if(topLayout != null){ if(topLayout != null){
if (clickTopLayout != null && clickTopLayout != topLayout){ if (clickTopLayout != null && clickTopLayout != topLayout && !isCreatorInLayout(clickTopLayout, topLayout)){
clickTopLayout.setEditable(false); clickTopLayout.setEditable(false);
setTopLayoutUnEditable(clickTopLayout, topLayout);
} }
clickTopLayout = topLayout; clickTopLayout = topLayout;
if(!topLayout.isEditable()) { if(!topLayout.isEditable()) {
@ -431,6 +462,7 @@ public class EditingMouseListener extends MouseInputAdapter {
else{ else{
if(clickTopLayout != null){ if(clickTopLayout != null){
clickTopLayout.setEditable(false); clickTopLayout.setEditable(false);
setTopLayoutUnEditable(clickTopLayout, null);
} }
} }

7
designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -9,6 +9,7 @@ import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent; import java.awt.dnd.DropTargetEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JWindow; import javax.swing.JWindow;
@ -85,8 +86,12 @@ public class FormCreatorDropTarget extends DropTarget {
if (success) { if (success) {
// 如果添加成功,则触发相应事件 // 如果添加成功,则触发相应事件
XCreator xCreator = container.acceptType(XWParameterLayout.class) ? designer.getParaComponent() : designer.getRootComponent(); XCreator xCreator = container.acceptType(XWParameterLayout.class) ? designer.getParaComponent() : designer.getRootComponent();
//SetSelection时要确保选中的是最顶层的布局
//tab布局添加的时候是初始化了XWCardLayout,实际上最顶层的布局是XWCardMainBorderLayout
XCreator addingXCreator = addingModel.getXCreator();
Widget widget = (addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData();
designer.getSelectionModel().setSelectedCreators( designer.getSelectionModel().setSelectedCreators(
FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{addingModel.getXCreator().toData()})); FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget}));
designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED); designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED);
} else { } else {
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();

Loading…
Cancel
Save