Browse Source

Merge pull request #628 in BA/design from ~LEE/design:dev to dev

* commit '36624f09ce9a2b5a40dbb021943d8387ea02e348':
  调整格式
  调整一下
  调整一下
  调整一下
  REPORT-576 tab属性部分添加
master
superman 8 years ago
parent
commit
7d50ddc86e
  1. 3
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  2. 45
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  3. 170
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

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

@ -148,7 +148,6 @@ public class XCardAddButton extends XButton{
//设置标题 //设置标题
titleButton.setText(getTabTitleName()); titleButton.setText(getTabTitleName());
XCardSwitchButton showButton = new XCardSwitchButton(titleButton,dimension,cardLayout,tagLayout); XCardSwitchButton showButton = new XCardSwitchButton(titleButton,dimension,cardLayout,tagLayout);
titleButton.setCustomStyle(true);
titleButton.setShowButton(true); titleButton.setShowButton(true);
showButton.setBackupParent(tagLayout); showButton.setBackupParent(tagLayout);
@ -162,6 +161,8 @@ public class XCardAddButton extends XButton{
private void showNewTab(EditingMouseListener editingMouseListener,int index){ private void showNewTab(EditingMouseListener editingMouseListener,int index){
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); SelectionModel selectionModel = editingMouseListener.getSelectionModel();
XWTabFitLayout tabFitLayout = (XWTabFitLayout) cardLayout.getComponent(index); XWTabFitLayout tabFitLayout = (XWTabFitLayout) cardLayout.getComponent(index);
XCardSwitchButton xCardSwitchButton = (XCardSwitchButton) this.tagLayout.getComponent(index);
tabFitLayout.setxCardSwitchButton(xCardSwitchButton);
selectionModel.setSelectedCreator(tabFitLayout); selectionModel.setSelectedCreator(tabFitLayout);
} }

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

@ -42,10 +42,14 @@ import com.fr.general.Inter;
*/ */
public class XCardSwitchButton extends XButton { public class XCardSwitchButton extends XButton {
private XWCardLayout cardLayout;
private XWCardTagLayout tagLayout;
private static final int LEFT_GAP = 16; private static final int LEFT_GAP = 16;
private static Icon MOUSE_COLSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png");
//设置的图片类型
private static final String COLORBACKGROUNDTYPE = "ColorBackground";
private static final String DEFAULTTYPE = "default";
//默认颜色
public static final Color NORMAL_GRAL = new Color(236,236,236); public static final Color NORMAL_GRAL = new Color(236,236,236);
public static final Color CHOOSED_GRAL = new Color(222,222,222); public static final Color CHOOSED_GRAL = new Color(222,222,222);
@ -58,9 +62,13 @@ public class XCardSwitchButton extends XButton {
// tab按钮里的字体因为按钮内部的布局看起来比正常的要小,加个调整量 // tab按钮里的字体因为按钮内部的布局看起来比正常的要小,加个调整量
private static final int FONT_SIZE_ADJUST = 2; private static final int FONT_SIZE_ADJUST = 2;
private XWCardLayout cardLayout;
private XWCardTagLayout tagLayout;
private Background selectBackground;
private boolean isCustomStyle;
private static Icon MOUSE_COLSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png");
private Icon closeIcon = MOUSE_COLSE; private Icon closeIcon = MOUSE_COLSE;
public XWCardTagLayout getTagLayout() { public XWCardTagLayout getTagLayout() {
@ -79,6 +87,22 @@ public class XCardSwitchButton extends XButton {
this.cardLayout = cardLayout; this.cardLayout = cardLayout;
} }
public boolean isCustomStyle() {
return isCustomStyle;
}
public void setCustomStyle(boolean customStyle) {
isCustomStyle = customStyle;
}
public Background getSelectBackground() {
return selectBackground;
}
public void setSelectBackground(Background selectBackground) {
this.selectBackground = selectBackground;
}
public XCardSwitchButton(CardSwitchButton widget, Dimension initSize) { public XCardSwitchButton(CardSwitchButton widget, Dimension initSize) {
super(widget, initSize); super(widget, initSize);
} }
@ -134,6 +158,7 @@ public class XCardSwitchButton extends XButton {
// 切换到当前tab按钮对应的tabFitLayout // 切换到当前tab按钮对应的tabFitLayout
XWTabFitLayout tabFitLayout = (XWTabFitLayout) cardLayout.getComponent(index); XWTabFitLayout tabFitLayout = (XWTabFitLayout) cardLayout.getComponent(index);
tabFitLayout.setxCardSwitchButton(this);
selectionModel.setSelectedCreator(tabFitLayout); selectionModel.setSelectedCreator(tabFitLayout);
if (editingMouseListener.stopEditing()) { if (editingMouseListener.stopEditing()) {
@ -248,6 +273,11 @@ public class XCardSwitchButton extends XButton {
//画背景 //画背景
private void drawBackgorund(){ private void drawBackgorund(){
CardSwitchButton button = (CardSwitchButton)this.toData(); CardSwitchButton button = (CardSwitchButton)this.toData();
Background currentBackground;
currentBackground = this.getSelectBackground();
//这边就是button的背景图片,图片的是image,默认的是color,所以不应该是针对null的判断
String type = currentBackground != null? currentBackground.getBackgroundType() : DEFAULTTYPE;
if (type.equals(COLORBACKGROUNDTYPE) || type.equals(DEFAULTTYPE)) {
ColorBackground background; ColorBackground background;
if(button.isShowButton()){ if(button.isShowButton()){
this.rebuid(); this.rebuid();
@ -259,6 +289,7 @@ public class XCardSwitchButton extends XButton {
this.setContentBackground(background); this.setContentBackground(background);
} }
} }
}
//画标题 //画标题
private void drawTitle() { private void drawTitle() {
@ -279,10 +310,12 @@ public class XCardSwitchButton extends XButton {
label.setForeground(font.getForeground()); label.setForeground(font.getForeground());
Background background = title.getBackground(); Background background = title.getBackground();
if (background != null) { if (background != null) {
if(button.isShowButton()){ if(button.isShowButton() && selectBackground != null){
this.setContentBackground(selectBackground);
}else if (button.isShowButton() && selectBackground == null){
background = ColorBackground.getInstance(CHOOSED_GRAL); background = ColorBackground.getInstance(CHOOSED_GRAL);
this.setContentBackground(background); this.setContentBackground(background);
}else{ } else {
this.setContentBackground(background); this.setContentBackground(background);
} }
} }

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

@ -1,12 +1,11 @@
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import java.awt.Component; import java.awt.*;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import javax.swing.border.Border; import javax.swing.border.Border;
import com.fr.base.background.ColorBackground;
import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
@ -14,19 +13,24 @@ import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.XCreator; 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.XWFitLayout; import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.properties.mobile.BodyMobilePropertyUI;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormHierarchyTreePane; import com.fr.design.mainframe.FormHierarchyTreePane;
import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; import com.fr.design.mainframe.widget.editors.ButtonTypeEditor;
import com.fr.design.mainframe.widget.renderer.PaddingMarginCellRenderer; import com.fr.design.mainframe.widget.editors.FontEditor;
import com.fr.design.mainframe.widget.editors.ImgBackgroundEditor;
import com.fr.design.mainframe.widget.renderer.FontCellRenderer;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.Background;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.core.PropertyChangeAdapter;
/** /**
* @author focus * @author focus
@ -37,8 +41,13 @@ public class XWTabFitLayout extends XWFitLayout {
private static final int MIN_SIZE = 1; private static final int MIN_SIZE = 1;
// tab布局在拖拽导致的缩放里(含间隔时),如果拖拽宽高大于组件宽高,会导致调整的时候找不到原来的组件 // tab布局在拖拽导致的缩放里(含间隔时),如果拖拽宽高大于组件宽高,会导致调整的时候找不到原来的组件
// 这里先将拖拽之前的宽高先做备份 // 这里先将拖拽之前的宽高先做备份
public static final Color NORMAL_GRAL = new Color(236,236,236);
public static final Color CHOOSED_GRAL = new Color(222,222,222);
private Dimension referDim; private Dimension referDim;
private Background initialBackground;
private Background overBackground;
private Background clickBackground;
private XCardSwitchButton xCardSwitchButton;
public Dimension getReferDim() { public Dimension getReferDim() {
return referDim; return referDim;
@ -48,6 +57,38 @@ public class XWTabFitLayout extends XWFitLayout {
this.referDim = referDim; this.referDim = referDim;
} }
public Background getInitialBackground() {
return initialBackground;
}
public void setInitialBackground(Background initialBackground) {
this.initialBackground = initialBackground;
}
public Background getOverBackground() {
return overBackground;
}
public void setOverBackground(Background overBackground) {
this.overBackground = overBackground;
}
public Background getClickBackground() {
return clickBackground;
}
public void setClickBackground(Background clickBackground) {
this.clickBackground = clickBackground;
}
public XCardSwitchButton getxCardSwitchButton() {
return xCardSwitchButton;
}
public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) {
this.xCardSwitchButton = xCardSwitchButton;
}
public XWTabFitLayout(){ public XWTabFitLayout(){
this(new WTabFitLayout(), new Dimension()); this(new WTabFitLayout(), new Dimension());
} }
@ -62,15 +103,118 @@ public class XWTabFitLayout extends XWFitLayout {
* @throws IntrospectionException * @throws IntrospectionException
*/ */
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return new CRPropertyDescriptor[] { checkButonType();
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter CRPropertyDescriptor[] crp = ((WTabFitLayout) data).isCustomStyle() ? getisCustomStyle() : getisnotCustomStyle();
.getLocText("FR-Designer_Form-Widget_Name")), return ArrayUtils.addAll(super.supportedDescriptor(), crp);
new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) }
.setI18NName(Inter.getLocText("FR-Designer_Layout-Padding"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), protected CRPropertyDescriptor[] getisCustomStyle() throws IntrospectionException {
return new CRPropertyDescriptor[]{
//标题样式
creatNonListenerStyle(0).setPropertyChangeListener(new PropertyChangeAdapter() {
@Override
public void propertyChange() {
checkButonType();
}
}),
//初始背景
creatNonListenerStyle(1).setPropertyChangeListener(new PropertyChangeAdapter() {
@Override
public void propertyChange() {
initialBackground = ((WTabFitLayout) data).getInitialBackground();
xCardSwitchButton.setSelectBackground(null);
xCardSwitchButton.setSelectBackground(initialBackground);
CardSwitchButton cardSwitchButton = (CardSwitchButton) xCardSwitchButton.toData();
cardSwitchButton.setInitialBackground(initialBackground);
}
}),
//鼠标浮动背景
creatNonListenerStyle(2).setPropertyChangeListener(
new PropertyChangeAdapter() {
@Override
public void propertyChange() {
overBackground = ((WTabFitLayout) data).getOverBackground();
CardSwitchButton cardSwitchButton = (CardSwitchButton) xCardSwitchButton.toData();
cardSwitchButton.setOverBackground(overBackground);
}
}),
//鼠标点击背景
creatNonListenerStyle(3).setPropertyChangeListener(
new PropertyChangeAdapter() {
@Override
public void propertyChange() {
clickBackground = ((WTabFitLayout) data).getClickBackground();
CardSwitchButton cardSwitchButton = (CardSwitchButton) xCardSwitchButton.toData();
cardSwitchButton.setClickBackground(clickBackground);
}
}
),
//字体
creatNonListenerStyle(4).setPropertyChangeListener(
new PropertyChangeAdapter() {
@Override
public void propertyChange() {
}
}),
}; };
} }
protected CRPropertyDescriptor[] getisnotCustomStyle() throws IntrospectionException {
return new CRPropertyDescriptor[]{
new CRPropertyDescriptor("customStyle", this.data.getClass()).setI18NName(
Inter.getLocText(new String[]{"Title", "Style"})).setEditorClass(
ButtonTypeEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced")
.setPropertyChangeListener(new PropertyChangeAdapter() {
@Override
public void propertyChange() {
checkButonType();
}
})
};
}
protected CRPropertyDescriptor creatNonListenerStyle(int i) throws IntrospectionException{
CRPropertyDescriptor[] crPropertyDescriptors = {
new CRPropertyDescriptor("customStyle", this.data.getClass()).setI18NName(
Inter.getLocText(new String[]{"Title", "Style"})).setEditorClass(
ButtonTypeEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
new CRPropertyDescriptor("initialBackground", this.data.getClass()).setEditorClass(
ImgBackgroundEditor.class).setI18NName(Inter.getLocText("FR-Designer_Background-Initial")).putKeyValue(
XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
new CRPropertyDescriptor("overBackground", this.data.getClass()).setEditorClass(
ImgBackgroundEditor.class).setI18NName(Inter.getLocText("FR-Designer_Background-Over")).putKeyValue(
XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
new CRPropertyDescriptor("clickBackground", this.data.getClass()).setEditorClass(
ImgBackgroundEditor.class).setI18NName(Inter.getLocText("FR-Designer_Background-Click")).putKeyValue(
XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
new CRPropertyDescriptor("font", this.data.getClass()).setI18NName(Inter.getLocText("FR-Designer_FRFont"))
.setEditorClass(FontEditor.class).setRendererClass(FontCellRenderer.class).putKeyValue(
XCreatorConstants.PROPERTY_CATEGORY, "Advanced")
};
return crPropertyDescriptors[i];
}
private void checkButonType() {
if (this.xCardSwitchButton == null) {
return;
}
boolean isStyle = ((WTabFitLayout) data).isCustomStyle();
Background bg;
bg = ColorBackground.getInstance(NORMAL_GRAL);
if (!isStyle) {
this.xCardSwitchButton.setCustomStyle(false);
this.xCardSwitchButton.setSelectBackground(bg);
} 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);
}
}
@Override @Override
public LayoutAdapter getLayoutAdapter() { public LayoutAdapter getLayoutAdapter() {
return new FRTabFitLayoutAdapter(this); return new FRTabFitLayoutAdapter(this);

Loading…
Cancel
Save