Browse Source

REPORT-2615 tab控件树结构调整

kerry 8 years ago
parent
commit
ffeb0a70b1
  1. 3
      designer_form/src/com/fr/design/designer/creator/XElementCase.java
  2. 10
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  3. 19
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  4. 10
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  5. 14
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  6. 13
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java
  7. 7
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  8. 6
      designer_form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java
  9. 13
      designer_form/src/com/fr/design/designer/treeview/ComponentTreeModel.java
  10. 16
      designer_form/src/com/fr/design/mainframe/ComponentTree.java

3
designer_form/src/com/fr/design/designer/creator/XElementCase.java

@ -119,9 +119,10 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
ReportFitAttrProvider fitAttr = wbTpl.getFitAttr(); ReportFitAttrProvider fitAttr = wbTpl.getFitAttr();
ElementCaseEditor editor = this.toData(); ElementCaseEditor editor = this.toData();
//兼容之前报表块(之前三个选项为:默认 横向 双向 现在是:横向 双向 不自适应) //兼容之前报表块(之前三个选项为:默认 横向 双向 现在是:横向 双向 不自适应)
if (editor.getFitStateInPC() == 0) { if (editor.getFitStateInPC() == 0 || processor.getFitStateInPC(fitAttr) == 0 ) {
editor.setReportFitAttr(null); editor.setReportFitAttr(null);
} }
ReportFitAttrProvider reportFit = editor.getReportFitAttr(); ReportFitAttrProvider reportFit = editor.getReportFitAttr();
if(fitAttr != null){ if(fitAttr != null){
reportFit = fitAttr.fitInBrowser() ? editor.getReportFitAttr() : fitAttr; reportFit = fitAttr.fitInBrowser() ? editor.getReportFitAttr() : fitAttr;

10
designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java

@ -160,7 +160,7 @@ public class XCardSwitchButton extends XButton {
//关闭重新打开,相关的layout未存到xml中,初始化 //关闭重新打开,相关的layout未存到xml中,初始化
if(cardLayout == null){ if(cardLayout == null){
initRelateLayout(this); initRelateLayout();
} }
//获取当前tab的index //获取当前tab的index
@ -254,7 +254,7 @@ public class XCardSwitchButton extends XButton {
//SwitchButton对应的XWCardLayout和XWCardTagLayout暂未存到xml中,重新打开时根据父子层关系获取 //SwitchButton对应的XWCardLayout和XWCardTagLayout暂未存到xml中,重新打开时根据父子层关系获取
private void initRelateLayout(XCardSwitchButton button){ private void initRelateLayout(){
this.tagLayout = (XWCardTagLayout)this.getBackupParent(); this.tagLayout = (XWCardTagLayout)this.getBackupParent();
XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.tagLayout.getBackupParent(); XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.tagLayout.getBackupParent();
XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent(); XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent();
@ -353,7 +353,7 @@ public class XCardSwitchButton extends XButton {
this.setButtonText(titleText); this.setButtonText(titleText);
if (this.cardLayout == null) { if (this.cardLayout == null) {
initRelateLayout(this); initRelateLayout();
} }
LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle(); LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle();
@ -418,6 +418,10 @@ public class XCardSwitchButton extends XButton {
public XCreator getXCreator() { public XCreator getXCreator() {
//根据index获取对应的tabFitLayout //根据index获取对应的tabFitLayout
int index = ((CardSwitchButton) this.toData()).getIndex(); int index = ((CardSwitchButton) this.toData()).getIndex();
//关闭重新打开,相关的layout未存到xml中,初始化
if(cardLayout == null){
initRelateLayout();
}
return (XCreator) cardLayout.getComponent(index); return (XCreator) cardLayout.getComponent(index);
} }

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

@ -40,9 +40,11 @@ import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.ContainerEvent; import java.awt.event.ContainerEvent;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.util.ArrayList;
/** /**
* @author richer * @author richer
@ -222,16 +224,25 @@ public class XWCardLayout extends XLayoutContainer {
return xFirstBtn; return xFirstBtn;
} }
/**
* 控件树不显示此组件
* @param path 控件树list
*/
public void notShowInComponentTree(ArrayList<Component> path) {
path.remove(0);
}
/** /**
* 设置父容器的名字 * 设置父容器的名字
* *
* @param parentPanel 当前父容器 * @param parentPanel 当前父容器
* @param widgetName 当前控件名 * @param widgetName 当前控件名
* *
* *
* @date 2014-11-27-上午9:47:00 * @date 2014-11-27-上午9:47:00
* *
*/ */
protected void setWrapperName(XLayoutContainer parentPanel, String widgetName) { protected void setWrapperName(XLayoutContainer parentPanel, String widgetName) {
parentPanel.toData().setWidgetName("tablayout" + widgetName.replaceAll(createDefaultName(),"")); parentPanel.toData().setWidgetName("tablayout" + widgetName.replaceAll(createDefaultName(),""));

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

@ -98,6 +98,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
super.add(comp, position); super.add(comp, position);
} }
/** /**
* 切换到非添加状态 * 切换到非添加状态
* *
@ -152,7 +153,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
* @param path 控件树list * @param path 控件树list
*/ */
public void notShowInComponentTree(ArrayList<Component> path) { public void notShowInComponentTree(ArrayList<Component> path) {
path.remove(LAYOUT_INDEX); return;
} }
@Override @Override
@ -308,6 +309,13 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
} }
} }
public int getIndexOfChild(Object child) {
if(child instanceof XWCardTagLayout){
return 0;
}
return -1;
}
/** /**
* data属性改变触发其他操作 * data属性改变触发其他操作
* *

14
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java

@ -10,7 +10,6 @@ import java.awt.FontMetrics;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.ContainerEvent; import java.awt.event.ContainerEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -252,8 +251,17 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
return this.getBackupParent().getTopLayout(); return this.getBackupParent().getTopLayout();
} }
public void notShowInComponentTree(ArrayList<Component> path) {
path.remove(0); public int getIndexOfChild(Object child) {
XLayoutContainer cardPart = ((XWCardMainBorderLayout)this.getTopLayout()).getCardPart();
int count = cardPart.getComponentCount();
for (int i = 0; i < count; i++) {
Component comp = cardPart.getComponent(i);
if (comp == child) {
return i;
}
}
return -1;
} }
public boolean isSupportDrag(){ public boolean isSupportDrag(){

13
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java

@ -3,8 +3,10 @@
*/ */
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.border.Border; import javax.swing.border.Border;
@ -33,6 +35,9 @@ public class XWCardTitleLayout extends XWBorderLayout {
private static final int CENTER = 1; private static final int CENTER = 1;
private static final int LAYOUT_INDEX = 0;
/** /**
* 构造函数 * 构造函数
*/ */
@ -51,6 +56,14 @@ public class XWCardTitleLayout extends XWBorderLayout {
public WTabDisplayPosition getDisplayPosition(){ public WTabDisplayPosition getDisplayPosition(){
return ((WCardTagLayout)this.getTagPart().toData()).getDisplayPosition(); return ((WCardTagLayout)this.getTagPart().toData()).getDisplayPosition();
} }
/**
* 控件树不显示此组件
* @param path 控件树list
*/
public void notShowInComponentTree(ArrayList<Component> path) {
path.remove(LAYOUT_INDEX);
}
/** /**
* 将WLayout转换为XLayoutContainer * 将WLayout转换为XLayoutContainer

7
designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

@ -27,7 +27,12 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.*; import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Rectangle;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;

6
designer_form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java

@ -25,12 +25,6 @@ public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof XCreator) { if (value instanceof XCreator) {
String name = ((XCreator) value).toData().getWidgetName(); String name = ((XCreator) value).toData().getWidgetName();
//树节点上不显示此控件
if(value instanceof XWCardLayout){
this.setSize(new Dimension(0, 0));
this.setPreferredSize(new Dimension(0, 0));
return this;
}
setText(name); setText(name);
Icon icon = XCreatorUtils.getCreatorIcon((XCreator) value); Icon icon = XCreatorUtils.getCreatorIcon((XCreator) value);
if (icon != null) { if (icon != null) {

13
designer_form/src/com/fr/design/designer/treeview/ComponentTreeModel.java

@ -10,7 +10,12 @@ import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.designer.creator.*; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
@ -23,6 +28,8 @@ public class ComponentTreeModel implements TreeModel {
private final int ABSOLUTE_AS_BODY_NOT_FOUND = -1; private final int ABSOLUTE_AS_BODY_NOT_FOUND = -1;
private final int CARDMAINLAYOUT_CHILD_COUNT = 1;
public ComponentTreeModel(FormDesigner designer, Component root) { public ComponentTreeModel(FormDesigner designer, Component root) {
this.designer = designer; this.designer = designer;
this.root = root; this.root = root;
@ -58,10 +65,14 @@ public class ComponentTreeModel implements TreeModel {
@Override @Override
public int getChildCount(Object parent) { public int getChildCount(Object parent) {
if(parent instanceof XWCardMainBorderLayout){
return CARDMAINLAYOUT_CHILD_COUNT;
}
if (parent != null && parent instanceof XLayoutContainer) { if (parent != null && parent instanceof XLayoutContainer) {
XLayoutContainer xlayout = (XLayoutContainer) parent; XLayoutContainer xlayout = (XLayoutContainer) parent;
return xlayout.getXCreatorCount(); return xlayout.getXCreatorCount();
} }
return 0; return 0;
} }

16
designer_form/src/com/fr/design/mainframe/ComponentTree.java

@ -5,6 +5,8 @@ import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.treeview.ComponentTreeCellRenderer; import com.fr.design.designer.treeview.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel; import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.gui.itree.UITreeUI; import com.fr.design.gui.itree.UITreeUI;
@ -15,7 +17,13 @@ import javax.swing.*;
import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel; import javax.swing.tree.TreeSelectionModel;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -218,10 +226,12 @@ public class ComponentTree extends JTree {
while (parent != null) { while (parent != null) {
XCreator creator = (XCreator) parent; XCreator creator = (XCreator) parent;
path.add(0, parent); path.add(0, parent);
if (creator != comp) { if (creator != comp) {
creator.notShowInComponentTree(path); creator.notShowInComponentTree(path);
} }
//绝对布局作为body的时候不显示自适应布局父层 //绝对布局作为body的时候不显示自适应布局父层
if (((XCreator) parent).acceptType(XWAbsoluteBodyLayout.class)) { if (((XCreator) parent).acceptType(XWAbsoluteBodyLayout.class)) {
if ((parent.getParent() != null) if ((parent.getParent() != null)
@ -230,6 +240,10 @@ public class ComponentTree extends JTree {
continue; continue;
} }
} }
if(((XCreator) parent).acceptType(XWCardLayout.class)){
parent = ((XWCardMainBorderLayout)parent.getParent()).getTitlePart().getTagPart();
continue;
}
parent = parent.getParent(); parent = parent.getParent();
} }

Loading…
Cancel
Save