Browse Source

Merge pull request #1590 in BA/design from ~KERRY/design:release/9.0 to release/9.0

* commit '321c74125a80dcfc10942aa06b323cbbb91454de':
  无
  无
  无
  REPORT-6463  tabpane相关问题
superman 7 years ago
parent
commit
bd7cbdd534
  1. 2
      designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java
  2. 3
      designer_form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java
  3. 3
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  4. 1
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveAction.java
  5. 7
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  6. 29
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  7. 37
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  8. 56
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  9. 19
      designer_form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java
  10. 2
      designer_form/src/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java
  11. 9
      designer_form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java

2
designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java

@ -43,8 +43,8 @@ public class TemplateStylePane extends BasicPane {
listModel.addElement(new CardTemplateStyle());
listModel.addElement(new BannerTemplateStyle());
listModel.addElement(new BookMarkTemplateStyle());
listModel.addElement(new PentagonTemplateStyle());
listModel.addElement(new MenuTemplateStyle());
listModel.addElement(new PentagonTemplateStyle());
listModel.addElement(new TrapezoidTemplateStyle());
styleList = new JList(listModel);
styleList.setCellRenderer(render);

3
designer_form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java

@ -48,11 +48,8 @@ public class FormDeleteAction extends FormWidgetEditAction {
if (designer == null) {
return false;
}
FormSelection selection = designer.getSelectionModel().getSelection();
XCreator creator = selection.getSelectedCreator();
designer.getSelectionModel().deleteSelection();
creator.deleteRelatedComponent(creator, designer);
return false;
}
}

3
designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java

@ -234,7 +234,6 @@ public class SelectionModel {
*/
public void deleteSelection() {
XCreator[] roots = selection.getSelectedCreators();
if (roots.length > 0) {
boolean isInPara = true; // 在参数面板内删除控件
for (XCreator creator : roots) {
@ -245,10 +244,12 @@ public class SelectionModel {
designer.removeParaComponent();
}
removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight());
creator.deleteRelatedComponent(creator, designer);
creator.removeAll();
// 清除被选中的组件
selection.reset();
}
setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent());
// 触发事件
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED);

1
designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveAction.java

@ -35,6 +35,7 @@ public class TabMoveAction extends FormUndoableAction {
moveTabAction(xwCardTagLayout, currentButton, xCurrentTab, currentTab);
xwCardTagLayout.setSwitchingTab(false);
xwCardTagLayout.doLayout();
}catch (Exception e){
xwCardTagLayout.setSwitchingTab(false);
FRLogger.getLogger().error(e.getMessage());

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

@ -31,6 +31,7 @@ import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WCardTitleLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
@ -59,6 +60,8 @@ public class XWCardLayout extends XLayoutContainer {
private static final int LAYOUT_INDEX = 0;
public static final String DEFAULT_NAME = "cardlayout";
//默认蓝色标题背景
private static final Color TITLE_COLOR = new Color(51, 132, 240);
@ -83,7 +86,7 @@ public class XWCardLayout extends XLayoutContainer {
*/
@Override
public String createDefaultName() {
return "cardlayout";
return DEFAULT_NAME;
}
/**
@ -210,6 +213,7 @@ public class XWCardLayout extends XLayoutContainer {
Dimension dimension = new Dimension();
//放置标题的tab流式布局
WCardTagLayout tagLayout = new WCardTagLayout("tabpane" + widgetName.replaceAll(createDefaultName(), ""));
tagLayout.setNewTab(true);
XWCardTagLayout xTag = new XWCardTagLayout(tagLayout, dimension, this);
xTag.setBackupParent(xTitle);
@ -464,6 +468,7 @@ public class XWCardLayout extends XLayoutContainer {
selectionModel.setSelectedCreator(mainLayout);
selectionModel.deleteSelection();
}
@Override
public void setBorder(Border border) {
super.setBorder(border);

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

@ -19,8 +19,11 @@ import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WTabDisplayPosition;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WCardTitleLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
@ -126,9 +129,29 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
comp.setBackupParent(this);
}
}
dealCompatibility(wb);
isRefreshing = false;
}
private void dealCompatibility(WBorderLayout wb){
WCardMainBorderLayout ob = (WCardMainBorderLayout)wb;
WCardLayout cardLayout = ob.getCardPart();
//tab结构改变需要兼容以前的tab,重新命名tabpane
WCardTitleLayout wCardTitleLayout = ob.getTitlePart();
if(cardLayout == null || wCardTitleLayout == null){
return;
}
WCardTagLayout wCardTagLayout = wCardTitleLayout.getTagPart();
String tabpaneName = cardLayout.getWidgetName();
if (!wCardTagLayout.isNewTab()) {
wCardTagLayout.setWidgetName(tabpaneName);
cardLayout.setWidgetName(XWCardLayout.DEFAULT_NAME + tabpaneName.replaceAll(XWCardTagLayout.DEFAULT_NAME, ""));
wCardTagLayout.setNewTab(true);
wCardTagLayout.setNewTab(true);
}
}
/**
* 切换到非添加状态
*
@ -341,13 +364,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
*/
@Override
public XLayoutContainer getTopLayout() {
XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout();
if (xTopLayout != null && !xTopLayout.isEditable()){
return xTopLayout;
}
else{
return this;
}
}
@Override

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

@ -19,6 +19,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WCardLayout;
@ -56,6 +57,8 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
private static final int DEFAULT_BUTTON_HEIGHT = 40;
public static final String DEFAULT_NAME = "tabpane";
public CardSwitchButton getCurrentCard() {
return currentCard;
}
@ -163,7 +166,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
@Override
public String createDefaultName() {
return "tabpane";
return DEFAULT_NAME;
}
/**
@ -324,6 +327,8 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
int tabLength = this.getComponentCount();
Map<Integer, Integer> cardWidth = new HashMap<Integer, Integer>();
Map<Integer, Integer> cardHeight = new HashMap<Integer, Integer>();
XLayoutContainer parent = this.getBackupParent();
for (int i = 0; i < tabLength; i++) {
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
CardSwitchButton tempCard = (CardSwitchButton) temp.toData();
@ -351,17 +356,17 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
}
}
if(isHori()){
adjustTabsH(tabLength, cardWidth, cardHeight);
adjustTabsH(parent, tabLength, cardWidth, cardHeight);
}else {
adjustTabsV(tabLength, cardWidth, cardHeight);
adjustTabsV(parent, tabLength, cardWidth, cardHeight);
}
fixTitleLayout(parent);
}
public void adjustTabsH(int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
public void adjustTabsH(XLayoutContainer parent, int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
if (width == null) {
return;
}
XLayoutContainer parent = this.getBackupParent();
int tabPaneSize = parent.getHeight();
//调整XWCardTagLayout的高度
int tempX = 0;
@ -369,9 +374,6 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
Rectangle rectangle = this.getComponent(i).getBounds();
Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET;
Integer cardHeight = tabPaneSize;
if(cardHeight < DEFAULT_BUTTON_HEIGHT){
cardHeight = DEFAULT_BUTTON_HEIGHT;
}
rectangle.setBounds(tempX, 0, cardWidth, cardHeight);
tempX += cardWidth;
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
@ -394,11 +396,10 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
}
public void adjustTabsV(int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
public void adjustTabsV(XLayoutContainer parent, int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
if (width == null) {
return;
}
XLayoutContainer parent = this.getBackupParent();
int tabPaneSize = parent.getWidth();
int tempY = 0;
for (int i = 0; i < tabLength; i++) {
@ -406,13 +407,6 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
Integer cardWidth = tabPaneSize;
//先用这边的固定高度
Integer cardHeight = height.get(i) + HEIGHT_SIDE_OFFSET;
if(cardWidth < DEFAULT_BUTTON_HEIGHT){
cardWidth = DEFAULT_BUTTON_HEIGHT;
}
if(cardHeight < DEFAULT_BUTTON_HEIGHT){
cardHeight = DEFAULT_BUTTON_HEIGHT;
}
rectangle.setBounds(0, tempY, cardWidth, cardHeight);
tempY += cardHeight;
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
@ -421,4 +415,13 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
}
private void fixTitleLayout(XLayoutContainer parent){
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(formDesigner, parent);
if (layoutAdapter != null) {
parent.setBackupBound(parent.getBounds());
layoutAdapter.fix(parent);
}
}
}

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

@ -28,7 +28,12 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.core.PropertyChangeAdapter;
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;
@ -38,7 +43,7 @@ import java.beans.IntrospectionException;
*/
public class XWTabFitLayout extends XWFitLayout {
private static final int MIN_SIZE = 1;
private static final int MIN_SIZE = 0;
private static final int WIDTH_SIDE_OFFSET = 57;
@ -267,20 +272,21 @@ public class XWTabFitLayout extends XWFitLayout {
XWCardTagLayout tagLayout = titleLayout.getTagPart();
WCardTagLayout tag = (WCardTagLayout) tagLayout.toData();
//先删除对应的tab按钮
for(int i=0;i<tagLayout.getComponentCount();i++){
CardSwitchButton button = tag.getSwitchButton(i);
if(button.getIndex()==index){
tagLayout.remove(i);
break;
}
}
//删除整个tab布局
if(tag.getWidgetCount() <= MIN_SIZE){
deleteTabLayout(mainLayout,designer);
return;
}
//先删除对应的tab按钮
for(int i=0;i<tagLayout.getComponentCount();i++){
CardSwitchButton button = tag.getSwitchButton(i);
if(button.getIndex()==index){
tagLayout.remove(i);
break;
}
}
//刷新tab按钮和tabFitLayout的index
refreshIndex(tag,cardLayout,index);
@ -299,20 +305,20 @@ public class XWTabFitLayout extends XWFitLayout {
selectionModel.setSelectedCreator(designer.getRootComponent());
}
private void refreshIndex(WCardTagLayout tag,XWCardLayout cardLayout,int index){
for(int i=0;i<tag.getWidgetCount();i++){
CardSwitchButton button = tag.getSwitchButton(i);
XWTabFitLayout tempFit = (XWTabFitLayout) cardLayout.getComponent(i);
WTabFitLayout tempFitLayout = (WTabFitLayout) tempFit.toData();
int currentFitIndex = tempFitLayout.getIndex();
int buttonIndex = button.getIndex();
if(buttonIndex > index){
button.setIndex(--buttonIndex);
}
if(currentFitIndex > index){
tempFitLayout.setIndex(--currentFitIndex);
}
}
private void refreshIndex(WCardTagLayout tag, XWCardLayout cardLayout, int index) {
for (int i = 0; i < tag.getWidgetCount(); i++) {
CardSwitchButton button = tag.getSwitchButton(i);
XWTabFitLayout tempFit = (XWTabFitLayout) cardLayout.getComponent(i);
WTabFitLayout tempFitLayout = (WTabFitLayout) tempFit.toData();
int currentFitIndex = tempFitLayout.getIndex();
int buttonIndex = button.getIndex();
if (buttonIndex > index) {
button.setIndex(--buttonIndex);
}
if (currentFitIndex > index) {
tempFitLayout.setIndex(--currentFitIndex);
}
}
}
/**
@ -461,7 +467,7 @@ public class XWTabFitLayout extends XWFitLayout {
}
//控件树上显示其taglayout层
if ((cardSwitchButton != null)) {
return cardSwitchButton.getTagLayout();
return cardSwitchButton.getBackupParent();
}
return super.getParentShow();
}

19
designer_form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java

@ -92,15 +92,18 @@ public class CardTagLayoutBorderPane extends LayoutBorderPane {
return;
}
public LayoutBorderStyle update() {
LayoutBorderStyle style = new LayoutBorderStyle();
style.setBorderStyle(this.getBorderStyleCombo().getSelectedIndex());
style.setBorder(this.getCurrentLineCombo().getSelectedLineStyle());
style.setColor(this.getCurrentLineColorPane().getColor());
style.setBackground(this.getBackgroundPane().update());
style.setAlpha((float)(this.getNumberDragPane().updateBean()/this.getMaxNumber()));
return style;
public LayoutBorderStyle update() {
LayoutBorderStyle style = new LayoutBorderStyle();
if (this.getBorderStyle() != null) {
style.setStyle(this.getBorderStyle());
}
style.setBorderStyle(this.getBorderStyleCombo().getSelectedIndex());
style.setBorder(this.getCurrentLineCombo().getSelectedLineStyle());
style.setColor(this.getCurrentLineColorPane().getColor());
style.setBackground(this.getBackgroundPane().update());
style.setAlpha((float) (this.getNumberDragPane().updateBean() / this.getMaxNumber()));
return style;
}
protected void populateBorderType(){
return;

2
designer_form/src/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java

@ -92,8 +92,6 @@ public class LayoutBorderPreviewPane extends JPanel{
jp.setBounds(smallGAP,smallGAP, getWidth() - GAP, height);
borderStyle.paint(g, new Rectangle2D.Double(smallGAP, smallGAP, getWidth() - GAP, getHeight() - GAP));
jp.setFontObject(borderStyle.getTitle().getFrFont());
jp.setVisible(borderStyle.getType() == LayoutBorderStyle.TITLE);
}
}

9
designer_form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java

@ -2,6 +2,8 @@ package com.fr.design.widget.ui.designer.layout;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
@ -13,6 +15,8 @@ import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WCardTitleLayout;
import com.fr.general.Inter;
import javax.swing.BorderFactory;
@ -21,6 +25,7 @@ import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.UUID;
/**
* Created by ibm on 2017/8/2.
@ -75,7 +80,7 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBord
WCardLayout cardLayout = ob.getCardPart();
accessibleCardTagWLayoutBorderStyleEditor.setValue(ob.getBorderStyle());
setCarousel.setSelected(cardLayout.isCarousel());
IntervalPane.setVisible(ob.isCarousel());
IntervalPane.setVisible(cardLayout.isCarousel());
carouselInterval.setValue(cardLayout.getCarouselInterval());
}
@ -83,8 +88,8 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBord
@Override
public WCardMainBorderLayout updateBean() {
WCardMainBorderLayout layout = (WCardMainBorderLayout) creator.toData();
layout.setBorderStyle((LayoutBorderStyle) accessibleCardTagWLayoutBorderStyleEditor.getValue());
WCardLayout wCardLayout = layout.getCardPart();
wCardLayout.setBorderStyle((LayoutBorderStyle) accessibleCardTagWLayoutBorderStyleEditor.getValue());
wCardLayout.setCarousel(setCarousel.isSelected());
wCardLayout.setCarouselInterval((int)carouselInterval.getValue());
return layout;

Loading…
Cancel
Save