Browse Source

Merge pull request #675 in BA/design from ~ZHOUPING/design:dev to dev

* commit '8574411195c39649057321050a666ab957298aba':
  无JIRA任务 tab交互改良代码同步 release同步到dev
master
superman 8 years ago
parent
commit
acd2a36333
  1. 92
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  2. 33
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  3. 41
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

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

@ -12,6 +12,7 @@ import javax.swing.*;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.base.background.ColorBackground;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
@ -46,6 +47,7 @@ public class XCardSwitchButton extends XButton {
//设置的图片类型
private static final String COLORBACKGROUNDTYPE = "ColorBackground";
private static final String DEFAULTTYPE = "default";
private static final String DEFAULT_FONT_NAME = "SimSun";
//默认颜色
public static final Color NORMAL_GRAL = new Color(236,236,236);
@ -64,13 +66,14 @@ public class XCardSwitchButton extends XButton {
private static final int FONT_SIZE_ADJUST = 2;
private static final int SIDE_OFFSET = 57;
private static final int HEIGHT_OFFSET = 25;
private static final int FONT_SIZE = 9;
private XWCardLayout cardLayout;
private XWCardTagLayout tagLayout;
private Background selectBackground;
private boolean isCustomStyle;
private UILabel label;
private Icon closeIcon = MOUSE_COLSE;
@ -106,6 +109,14 @@ public class XCardSwitchButton extends XButton {
this.selectBackground = selectBackground;
}
public UILabel getLabel() {
return label;
}
public void setLabel(UILabel label) {
this.label = label;
}
public XCardSwitchButton(CardSwitchButton widget, Dimension initSize) {
super(widget, initSize);
}
@ -161,7 +172,8 @@ public class XCardSwitchButton extends XButton {
// 切换到当前tab按钮对应的tabFitLayout
XWTabFitLayout tabFitLayout = (XWTabFitLayout) cardLayout.getComponent(index);
tabFitLayout.setxCardSwitchButton(this);
XCardSwitchButton xCardSwitchButton = (XCardSwitchButton) this.tagLayout.getComponent(index);
tabFitLayout.setxCardSwitchButton(xCardSwitchButton);
selectionModel.setSelectedCreator(tabFitLayout);
if (editingMouseListener.stopEditing()) {
@ -242,6 +254,8 @@ public class XCardSwitchButton extends XButton {
int width = button.getWidth();
int height = button.getHeight();
ey = ey % DEFAULT_BUTTON_HEIGHT;
// 鼠标进入按钮右侧删除图标区域
double recX = position.getX() + (width - RIGHT_OFFSET);
double recY = position.getY() + (height - TOP_OFFSET);
@ -307,7 +321,10 @@ public class XCardSwitchButton extends XButton {
// 标题部分
WidgetTitle title = style.getTitle();
FRFont font = title.getFrFont();
FRFont font = button.getFont();
if (font == null) {
font = FRFont.getInstance(DEFAULT_FONT_NAME, 0, FONT_SIZE);
}
FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(),font.getSize() + FONT_SIZE_ADJUST);
UILabel label = this.getContentLabel();
label.setFont(newFont);
@ -327,6 +344,12 @@ public class XCardSwitchButton extends XButton {
//删除tab布局
private void deleteTabLayout(SelectionModel selectionModel,FormDesigner designer){
String titleName = this.getContentLabel().getText();
int value = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer_ConfirmDialog_Content") + "“" + titleName + "”",
Inter.getLocText("FR-Designer_ConfirmDialog_Title"),JOptionPane.YES_NO_OPTION);
if (value != JOptionPane.OK_OPTION) {
return;
}
XLayoutContainer mainLayout = this.cardLayout.getBackupParent();
if(mainLayout != null){
selectionModel.setSelectedCreator(mainLayout);
@ -342,31 +365,31 @@ public class XCardSwitchButton extends XButton {
return this.getBackupParent().getTopLayout();
}
public void setTabsAndAdjust() {
if (this.tagLayout == null) {
return;
}
int tabLength = this.tagLayout.getComponentCount();
Map<Integer, Integer> cardWidth = new HashMap<>();
Map<Integer, Integer> cardHeight = new HashMap<>();
for (int i = 0; i < tabLength; i++) {
XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i);
CardSwitchButton tempCard = (CardSwitchButton) temp.toData();
String tempText = tempCard.getText();
Font f = ((CardSwitchButton)this.toData()).getFont();
public void setTabsAndAdjust() {
if (this.tagLayout == null) {
return;
}
int tabLength = this.tagLayout.getComponentCount();
Map<Integer, Integer> cardWidth = new HashMap<>();
Map<Integer, Integer> cardHeight = new HashMap<>();
for (int i = 0; i < tabLength; i++) {
XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i);
CardSwitchButton tempCard = (CardSwitchButton) temp.toData();
String tempText = tempCard.getText();
Font f = tempCard.getFont();
FontMetrics fm = GraphHelper.getFontMetrics(f);
cardWidth.put(i,fm.stringWidth(tempText));
cardHeight.put(i,fm.getHeight());
}
adjustTabs(tabLength, cardWidth, cardHeight);
}
cardWidth.put(i,fm.stringWidth(tempText));
cardHeight.put(i,fm.getHeight());
}
adjustTabs(tabLength, cardWidth, cardHeight);
}
public void adjustTabs(int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
public void adjustTabs(int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
if (width == null) {
return;
}
int tempX = 0;
for (int i = 0; i < tabLength; i++) {
int tempX = 0;
for (int i = 0; i < tabLength; i++) {
Rectangle rectangle = this.tagLayout.getComponent(i).getBounds();
Integer cardWidth = width.get(i) + SIDE_OFFSET;
//先用这边的固定高度
@ -378,17 +401,30 @@ public class XCardSwitchButton extends XButton {
Dimension dimension = new Dimension();
dimension.setSize(cardWidth, cardHeight);
XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i);
CardSwitchButton cardSwitchButton = (CardSwitchButton) temp.toData();
FRFont frFont = cardSwitchButton.getFont();
if (frFont == null) {
frFont = FRFont.getInstance(DEFAULT_FONT_NAME, 0, FONT_SIZE);
}
UILabel label = temp.getContentLabel();
label.setSize(dimension);
label.setFont(frFont.applyResolutionNP(ScreenResolution.getScreenResolution()));
label.setForeground(frFont.getForeground());
temp.setContentLabel(label);
temp.setSize(dimension);
temp.setPreferredSize(new Dimension(cardWidth, cardHeight));
}
}
}
}
@Override
public void doLayout() {
super.doLayout();
setTabsAndAdjust();
}
@Override
public void doLayout() {
super.doLayout();
setTabsAndAdjust();
protected void initXCreatorProperties() {
super.initXCreatorProperties();
label = this.getContentLabel();
}
}

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

@ -271,34 +271,33 @@ public class XWCardLayout extends XLayoutContainer {
return true;
}
/**
* 得到属性名
* 得到属性名
* @return 属性名
* @throws IntrospectionException
*/
* @throws IntrospectionException
*/
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
CRPropertyDescriptor[] crp = ((WCardLayout) data).isCarousel() ? getisCarousel() : getisnotCarousel();
CRPropertyDescriptor[] crp = null;
return ArrayUtils.addAll(getDefaultDescriptor(), crp);
}
public CRPropertyDescriptor[] getisCarousel() throws IntrospectionException {
return new CRPropertyDescriptor[] {
new CRPropertyDescriptor("carousel", this.data.getClass())
.setEditorClass(BooleanEditor.class)
.setI18NName(Inter.getLocText("FR-Designer_setCarousel"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "FR-Designer_Tab_carousel")
.setPropertyChangeListener(new PropertyChangeAdapter() {
@Override
public void propertyChange() {
designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED);
}
.setEditorClass(BooleanEditor.class)
.setI18NName(Inter.getLocText("FR-Designer_setCarousel"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "FR-Designer_Tab_carousel")
.setPropertyChangeListener(new PropertyChangeAdapter() {
@Override
public void propertyChange() {
designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED);
}
}),
new CRPropertyDescriptor("carouselInterval", this.data.getClass())
.setEditorClass(DoubleEditor.class)
.setI18NName(Inter.getLocText("FR-Designer_carouselInterval"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "FR-Designer_Tab_carousel")
.setEditorClass(DoubleEditor.class)
.setI18NName(Inter.getLocText("FR-Designer_carouselInterval"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "FR-Designer_Tab_carousel")
};
}

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

@ -5,6 +5,7 @@ import java.beans.IntrospectionException;
import javax.swing.border.Border;
import com.fr.base.ScreenResolution;
import com.fr.base.background.ColorBackground;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter;
@ -15,6 +16,7 @@ import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormHierarchyTreePane;
import com.fr.design.mainframe.widget.editors.ButtonTypeEditor;
@ -43,6 +45,9 @@ public class XWTabFitLayout extends XWFitLayout {
// tab布局在拖拽导致的缩放里(含间隔时),如果拖拽宽高大于组件宽高,会导致调整的时候找不到原来的组件
// 这里先将拖拽之前的宽高先做备份
private static final Color NORMAL_GRAL = new Color(236,236,236);
private static final String DEFAULT_FONT_NAME = "SimSun";
public final static Font DEFAULTFT = new Font("Song_TypeFace",0,12);
public final static FRFont DEFAULT_FRFT = FRFont.getInstance(DEFAULT_FONT_NAME, 0, 9);
private Dimension referDim;
private Background initialBackground;
private Background overBackground;
@ -108,13 +113,12 @@ public class XWTabFitLayout extends XWFitLayout {
}
/**
* 得到属性名
* 得到属性名
* @return 属性名
* @throws IntrospectionException
*/
* @throws IntrospectionException
*/
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
checkButonType();
CRPropertyDescriptor[] crp = ((WTabFitLayout) data).isCustomStyle() ? getisCustomStyle() : getisnotCustomStyle();
CRPropertyDescriptor[] crp = null;
return ArrayUtils.addAll(defaultDescriptor(), crp);
}
@ -164,6 +168,13 @@ public class XWTabFitLayout extends XWFitLayout {
new PropertyChangeAdapter() {
@Override
public void propertyChange() {
font = ((WTabFitLayout) data).getFont();
CardSwitchButton cardSwitchButton = (CardSwitchButton) xCardSwitchButton.toData();
cardSwitchButton.setFont(font);
UILabel uiLabel = xCardSwitchButton.getLabel();
uiLabel.setFont(font.applyResolutionNP(ScreenResolution.getScreenResolution()));
uiLabel.setForeground(font.getForeground());
xCardSwitchButton.setLabel(uiLabel);
}
}),
};
@ -220,16 +231,34 @@ public class XWTabFitLayout extends XWFitLayout {
boolean isStyle = ((WTabFitLayout) data).isCustomStyle();
Background bg;
bg = ColorBackground.getInstance(NORMAL_GRAL);
CardSwitchButton cardSwitchButton = (CardSwitchButton) this.xCardSwitchButton.toData();
if (!isStyle) {
this.xCardSwitchButton.setCustomStyle(false);
this.xCardSwitchButton.setSelectBackground(bg);
this.xCardSwitchButton.getLabel().setFont(DEFAULTFT);
cardSwitchButton.setInitialBackground(null);
cardSwitchButton.setClickBackground(null);
cardSwitchButton.setOverBackground(null);
cardSwitchButton.setFont(DEFAULT_FRFT);
} else {
CardSwitchButton cardSwitchButton = (CardSwitchButton) this.xCardSwitchButton.toData();
Background initialBackground = cardSwitchButton.getInitialBackground();
bg = initialBackground == null ? bg : initialBackground;
this.xCardSwitchButton.setSelectBackground(bg);
this.xCardSwitchButton.setCustomStyle(true);
cardSwitchButton.setCustomStyle(true);
if (font != null) {
cardSwitchButton.setFont(font);
}
if (this.initialBackground != null){
this.xCardSwitchButton.setSelectBackground(this.initialBackground);
cardSwitchButton.setInitialBackground(this.initialBackground);
}
if (this.overBackground != null){
cardSwitchButton.setOverBackground(this.overBackground);
}
if (this.clickBackground != null) {
cardSwitchButton.setClickBackground(this.clickBackground);
}
}
}

Loading…
Cancel
Save