Browse Source

Merge pull request #1550 in BA/design from ~KERRY/design:feature/9.0 to feature/9.0

* commit '61b5557eff18b5ad074c8c5ab26e6040c4c162e9':
  REPORT-6251 新功能:tabpane显示的bug
  REPORT-6251 新功能:tabpane显示的bug
superman 8 years ago
parent
commit
8192c63df6
  1. 2
      designer_base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java
  2. 29
      designer_base/src/com/fr/design/widget/component/UIComboBoxNoArrow.java
  3. 6
      designer_form/src/com/fr/design/designer/creator/XButton.java
  4. 12
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  5. 108
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  6. 25
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  7. 30
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  8. 20
      designer_form/src/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java
  9. 15
      designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java

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

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

29
designer_base/src/com/fr/design/widget/component/UIComboBoxNoArrow.java

@ -9,9 +9,11 @@ import com.fr.stable.StringUtils;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.basic.BasicComboBoxUI;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
/**
* Created by kerry on 2017/9/14.
@ -66,14 +68,29 @@ public class UIComboBoxNoArrow extends UIComboBox {
super();
this.comboBox = comboBox;
textField.getDocument().addDocumentListener(this);
textField.addFocusListener(new FocusListener() {
textField.addMouseListener(new MouseListener() {
@Override
public void focusGained(FocusEvent e) {
public void mouseClicked(MouseEvent e) {
changeHandler();
}
@Override
public void focusLost(FocusEvent e) {
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});

6
designer_form/src/com/fr/design/designer/creator/XButton.java

@ -198,10 +198,14 @@ public class XButton extends XWidgetCreator {
protected JComponent initEditor() {
if (editor == null) {
editor = new UILabel();
contentLabel = new UILabel();
contentLabel = initContentLabel();
}
return editor;
}
protected UILabel initContentLabel() {
return new UILabel();
}
@Override
public void paintComponent(Graphics g) {

12
designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java

@ -29,13 +29,11 @@ public class XCardAddButton extends XButton{
private XWCardTagLayout tagLayout;
private XWCardLayout cardLayout;
private static final int LEFT_GAP = 5;
private static final int UP_GAP = 10;
private static final int START_INDEX = 3;
private static final int INDEX = 0;
private static final int DEFAULT_BUTTON_WIDTH = 80;
private static final int ICON_OFFSET = 8;
private static Icon ADD_ICON = BaseUtils.readIcon("/com/fr/design/form/images/add.png");
private Icon addIcon = ADD_ICON;
@ -128,7 +126,9 @@ public class XCardAddButton extends XButton{
}
private void drawAddIcon(Graphics2D g2d){
addIcon.paintIcon(this, g2d,LEFT_GAP,UP_GAP);
int width = this.getWidth();
int height = this.getHeight();
addIcon.paintIcon(this, g2d, width / 2 - ICON_OFFSET, height / 2 - ICON_OFFSET);
}
//将原来的tab页设置为未选中状态

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

@ -4,6 +4,7 @@
package com.fr.design.designer.creator.cardlayout;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.background.ColorBackground;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
@ -29,19 +30,24 @@ import com.fr.general.Background;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.Inter;
import com.fr.stable.unit.PT;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.plaf.basic.BasicLabelUI;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
/**
*
@ -73,6 +79,11 @@ public class XCardSwitchButton extends XButton {
// tab按钮里的字体因为按钮内部的布局看起来比正常的要小,加个调整量
private static final int FONT_SIZE_ADJUST = 2;
//文字竖排时用来计算文字大小
private static final int RESLUTION = 120;
private static final int DOTSLINESPACE = 6;
private XWCardLayout cardLayout;
private XWCardTagLayout tagLayout;
@ -124,7 +135,6 @@ public class XCardSwitchButton extends XButton {
public XCardSwitchButton(CardSwitchButton widget, Dimension initSize) {
super(widget, initSize);
}
public XCardSwitchButton(CardSwitchButton widget, Dimension initSize,
@ -340,31 +350,18 @@ public class XCardSwitchButton extends XButton {
private void drawTitle() {
CardSwitchButton button = (CardSwitchButton) this.toData();
String titleText = button.getText();
if(tagLayout != null){
WCardTagLayout wCardTagLayout = (WCardTagLayout) tagLayout.toData();
StringBuilder titleString = new StringBuilder();
//竖向处理
if(ComparatorUtils.equals(wCardTagLayout.getTextDirection(), WTabTextDirection.TEXT_VER_DIRECTION)){
titleString.append("<html>");
for(int i = 0; i < titleText.length(); i++){
titleString.append(titleText.charAt(i)).append("<br/>");
}
titleString.append("</html>");
titleText = titleString.toString();
}
}
this.setButtonText(titleText);
if (this.cardLayout == null) {
initRelateLayout(this);
}
LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle();
LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle();
// 标题部分
WidgetTitle title = style.getTitle();
FRFont font = title.getFrFont();
FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(),font.getSize() + FONT_SIZE_ADJUST);
// 标题部分
WidgetTitle title = style.getTitle();
FRFont font = title.getFrFont();
FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(),font.getSize() + FONT_SIZE_ADJUST);
UILabel label = this.getContentLabel();
label.setFont(newFont);
label.setForeground(font.getForeground());
@ -436,4 +433,77 @@ public class XCardSwitchButton extends XButton {
tagLayout.setTabsAndAdjust();
repaint();
}
@Override
protected UILabel initContentLabel() {
return new CardSwitchBtnLabel();
}
public class CardSwitchBtnLabel extends UILabel{
public CardSwitchBtnLabel(){
updateUI();
}
@Override
public void updateUI() {
setUI(new CardSwitchBtnLabelUI());
}
}
public class CardSwitchBtnLabelUI extends BasicLabelUI{
@Override
public void paint(Graphics g, JComponent c)
{
Graphics2D g2d = (Graphics2D)g;
CardSwitchButton button = (CardSwitchButton) XCardSwitchButton.this.toData();
int width = XCardSwitchButton.this.getWidth();
int height= XCardSwitchButton.this.getHeight();
String titleText = button.getText();
LayoutBorderStyle style = cardLayout.toData().getBorderStyle();
WidgetTitle title = style.getTitle();
FRFont font = title.getFrFont();
FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(),font.getSize() + FONT_SIZE_ADJUST);
FontMetrics fm = GraphHelper.getFontMetrics(newFont);
WCardTagLayout wCardTagLayout = (WCardTagLayout) tagLayout.toData();
StringBuilder titleStringBuf = new StringBuilder();
//竖向处理
if(ComparatorUtils.equals(wCardTagLayout.getTextDirection(), WTabTextDirection.TEXT_VER_DIRECTION)){
java.util.List verticalTextList = new ArrayList();
for (int i = 0; i < titleText.length(); i++) {
titleStringBuf.append(titleText.charAt(i));
verticalTextList.add(titleStringBuf.substring(0, titleStringBuf.length()));
titleStringBuf.delete(0, titleStringBuf.length());
}
int textAscent = fm.getAscent();
int textHeight = fm.getHeight();
int textY = 0;
textY += textAscent;
for (int i = 0; i < verticalTextList.size(); i++) {
String paint_str = (String) verticalTextList.get(i);
GraphHelper.drawString(g2d, paint_str, (width - fm.stringWidth(paint_str)) / 2, textY);
textY += textHeight;
textY += PT.pt2pix(0, RESLUTION);
if (textY > height - textHeight && i < verticalTextList.size()-1) {
textY -= 10;
paintDots(g2d, textY, (width - fm.stringWidth(paint_str)) / 2);
break;
}
}
}else{
super.paint(g, c);
}
}
public void paintDots(Graphics2D g2d, int startY, int startX){
for (int i = 0; i < 3; i++) {
String paint_str = ".";
GraphHelper.drawString(g2d, paint_str, startX, startY);
startY += DOTSLINESPACE;//
startY += PT.pt2pix(0, RESLUTION);
}
}
}
}

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

@ -17,6 +17,7 @@ import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WTabDisplayPosition;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import java.awt.AlphaComposite;
@ -27,6 +28,7 @@ import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
@ -84,6 +86,14 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
this.add(title, position);
}
public int getTitleWidth(){
String position = toData().getTabPosition();
if(ComparatorUtils.equals(WBorderLayout.NORTH, position) || ComparatorUtils.equals(WBorderLayout.SOUTH, position)){
return getTitlePart().getHeight();
}
return getTitlePart().getWidth();
}
public void add(Component comp, String position) {
super.add(comp, position);
}
@ -309,23 +319,30 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
public void resetTabDisplayPosition(WTabDisplayPosition wTabDisplayPosition){
XWCardTitleLayout xwCardTitleLayout = getTitlePart();
int titleSize = getTitleWidth();
xwCardTitleLayout.resetNewBtnPosition(wTabDisplayPosition);
Rectangle parentBounds = new Rectangle(xwCardTitleLayout.getBounds());
switch (wTabDisplayPosition){
case TOP_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.NORTH);
this.addTitlePart(xwCardTitleLayout,WBorderLayout.NORTH);
parentBounds.height = titleSize;
break;
case LEFT_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.WEST);
this.addTitlePart(xwCardTitleLayout,WBorderLayout.WEST);
parentBounds.width = titleSize;
break;
case BOTTOM_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.SOUTH);
this.addTitlePart(xwCardTitleLayout,WBorderLayout.SOUTH);
parentBounds.height = titleSize;
break;
case RIGHT_POSITION:
this.addTitlePart(getTitlePart(),WBorderLayout.EAST);
this.addTitlePart(xwCardTitleLayout,WBorderLayout.EAST);
parentBounds.width = titleSize;
break;
default:
break;
}
xwCardTitleLayout.setBounds(parentBounds);
this.addCardPart((XWCardLayout)this.getComponent(0));
}
}

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

@ -256,9 +256,13 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
path.remove(0);
}
public boolean isSupportDrag(){
return false;
}
@Override
public void doLayout() {
setTabsAndAdjust();
//设置布局
super.doLayout();
}
@ -308,12 +312,11 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
repaint();
}
public void setTabsAndAdjust() {
WCardTagLayout wCardTagLayout = (WCardTagLayout)this.toData();
int tabLength = this.getComponentCount();
Map<Integer, Integer> cardWidth = new HashMap<>();
Map<Integer, Integer> cardHeight = new HashMap<>();
Map<Integer, Integer> cardWidth = new HashMap<Integer, Integer>();
Map<Integer, Integer> cardHeight = new HashMap<Integer, Integer>();
for (int i = 0; i < tabLength; i++) {
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
CardSwitchButton tempCard = (CardSwitchButton) temp.toData();
@ -351,18 +354,17 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
if (width == null) {
return;
}
XLayoutContainer parent = this.getBackupParent();
int tabPaneSize = parent.getHeight();
//调整XWCardTagLayout的高度
int tempX = 0;
int maxHeight = DEFAULT_BUTTON_HEIGHT;
for (int i = 0; i < tabLength; i++) {
Rectangle rectangle = this.getComponent(i).getBounds();
Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET;
Integer cardHeight = height.get(i)+ HEIGHT_SIDE_OFFSET ;
Integer cardHeight = tabPaneSize;
if(cardHeight < DEFAULT_BUTTON_HEIGHT){
cardHeight = DEFAULT_BUTTON_HEIGHT;
}
maxHeight = maxHeight > cardHeight ? maxHeight : cardHeight ;
rectangle.setBounds(tempX, 0, cardWidth, cardHeight);
tempX += cardWidth;
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
@ -370,10 +372,6 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
}
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
XLayoutContainer parent = this.getBackupParent();
Rectangle parentBounds = new Rectangle(parent.getBounds());
parentBounds.height = maxHeight;
parent.setBounds(parentBounds);
LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(formDesigner, parent);
if (layoutAdapter != null) {
parent.setBackupBound(parent.getBounds());
@ -400,12 +398,12 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
if (width == null) {
return;
}
XLayoutContainer parent = this.getBackupParent();
int tabPaneSize = parent.getWidth();
int tempY = 0;
int maxWidth = DEFAULT_BUTTON_HEIGHT;
for (int i = 0; i < tabLength; i++) {
Rectangle rectangle = this.getComponent(i).getBounds();
Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET;
maxWidth = maxWidth > cardWidth ? maxWidth : cardWidth;
Integer cardWidth = tabPaneSize;
//先用这边的固定高度
Integer cardHeight = height.get(i) + HEIGHT_SIDE_OFFSET;
@ -422,10 +420,6 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
}
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
XLayoutContainer parent = this.getBackupParent();
Rectangle parentBounds = new Rectangle(parent.getBounds());
parentBounds.width = maxWidth;
parent.setBounds(parentBounds);
LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(formDesigner, parent);
if (layoutAdapter != null) {
parent.setBackupBound(parent.getBounds());

20
designer_form/src/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java

@ -3,6 +3,8 @@ package com.fr.design.widget.ui.designer.component;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
@ -12,6 +14,7 @@ import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import javax.swing.JOptionPane;
import java.awt.Rectangle;
/**
@ -41,10 +44,21 @@ public class WidgetCardTagBoundPane extends WidgetBoundPane {
WCardTagLayout tagLayout = (WCardTagLayout)creator.toData();
WTabDisplayPosition displayPosition = tagLayout.getDisplayPosition();
if( ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){
parentBounds.height = (int)cardTagWidth.getValue();
int size = (int)cardTagWidth.getValue();
XLayoutContainer tabLayout = creator.getTopLayout();
Rectangle rectangle = tabLayout.getBounds();
if(ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){
if(rectangle.height < size){
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Beyond_Tablayout_Bounds"));
return;
}
parentBounds.height = size;
}else{
parentBounds.width = (int)cardTagWidth.getValue();
if(rectangle.width < size){
JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Beyond_Tablayout_Bounds"));
return;
}
parentBounds.width = size;
}
parent.setBounds(parentBounds);

15
designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java

@ -1,5 +1,6 @@
package com.fr.design.widget.ui.designer.layout;
import com.fr.general.ComparatorUtils;
import com.fr.general.cardtag.TemplateStyle;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
@ -58,7 +59,13 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
UILabel fontLabel = new UILabel(Inter.getLocText("FR-Designer_Font"));
fontLabel.setVerticalAlignment(SwingConstants.TOP);
frFontPane = new FRFontPane();
displayPositionGroup = new UIButtonGroup(WTabDisplayPosition.getStringArray());
displayPositionGroup = new UIButtonGroup(WTabDisplayPosition.getStringArray()){
@Override
public boolean shouldResponseNameListener() {
return true;
}
};
displayPositionGroup.setGlobalName(Inter.getLocText("FR-Designer_Tab_Style_Template"));
textDirectionGroup = new UIButtonGroup(WTabTextDirection.getStringArray());
Component[][] components = new Component[][]{
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Tab_Style_Template")), templateStyleEditor},
@ -105,7 +112,11 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
layoutBorderStyle.getTitle().setBackground((Background) backgroundEditor.getValue());
layoutBorderStyle.getTitle().setFrFont(frFontPane.update(frFont));
WCardTagLayout layout = (WCardTagLayout) creator.toData();
layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex()));
boolean isHori = displayPositionGroup.getSelectedIndex() == WTabDisplayPosition.TOP_POSITION.getType() || displayPositionGroup.getSelectedIndex() == WTabDisplayPosition.BOTTOM_POSITION.getType();
if(ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Tab_Style_Template"))){
layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex()));
textDirectionGroup.setSelectedIndex(isHori? WTabTextDirection.TEXT_HORI_DERECTION.getType():WTabTextDirection.TEXT_VER_DIRECTION.getType());
}
layout.setTextDirection(WTabTextDirection.parse(textDirectionGroup.getSelectedIndex()));
layout.setTemplateStyle((TemplateStyle) templateStyleEditor.getValue());

Loading…
Cancel
Save