Browse Source

Merge branch 'release/9.0' of ssh://cloud.finedevelop.com:7999/~hzzz/design into release/9.0

hzzz 7 years ago
parent
commit
ca670b202c
  1. 7
      designer_base/src/com/fr/design/data/datapane/ChoosePane.java
  2. 2
      designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java
  3. 2
      designer_base/src/com/fr/design/fun/SubmitProvider.java
  4. 13
      designer_base/src/com/fr/design/gui/icombobox/FRTreeComboBox.java
  5. 7
      designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java
  6. 39
      designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java
  7. 40
      designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java
  8. 95
      designer_base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java
  9. 10
      designer_base/src/com/fr/design/widget/component/BackgroundCompPane.java
  10. 3
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  11. 254
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  12. 4
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  13. 57
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  14. 5
      designer_form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPreviewPane.java
  15. 5
      designer_form/src/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java
  16. 8
      designer_form/src/com/fr/design/mainframe/ComponentTree.java
  17. 37
      designer_form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java
  18. 6
      designer_form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java
  19. 40
      designer_form/src/com/fr/design/widget/ui/designer/layout/WCardTagLayoutDefinePane.java
  20. 4
      designer_form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java

7
designer_base/src/com/fr/design/data/datapane/ChoosePane.java

@ -466,9 +466,12 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
protected String getTableName() { protected String getTableName() {
String tableName = ""; String tableName = "";
Object obj = this.tableNameComboBox.getSelectedItem(); Object obj = this.tableNameComboBox.getSelectedItemObject();
if (obj == null) { if (obj == null) {
obj = this.tableNameComboBox.getEditor().getItem(); obj = this.tableNameComboBox.getSelectedItem();
if (obj == null) {
obj = this.tableNameComboBox.getEditor().getItem();
}
} }
if (obj instanceof TreePath) { if (obj instanceof TreePath) {
Object tp = ((ExpandMutableTreeNode) ((TreePath) obj).getLastPathComponent()).getUserObject(); Object tp = ((ExpandMutableTreeNode) ((TreePath) obj).getLastPathComponent()).getUserObject();

2
designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java

@ -23,7 +23,7 @@ public class GetPluginFromStoreExecutor implements Executor {
private String scope; private String scope;
public GetPluginFromStoreExecutor(JSONObject info) { public GetPluginFromStoreExecutor(JSONObject info) {
this.category = info.optString("category"); this.category = info.optString("categories");
this.fee = info.optString("fee"); this.fee = info.optString("fee");
this.seller = info.optString("seller"); this.seller = info.optString("seller");
this.scope = info.optString("scope"); this.scope = info.optString("scope");

2
designer_base/src/com/fr/design/fun/SubmitProvider.java

@ -10,7 +10,7 @@ public interface SubmitProvider extends Mutable{
String MARK_STRING = "SubmitProvider"; String MARK_STRING = "SubmitProvider";
int CURRENT_LEVEL = 1; int CURRENT_LEVEL = 2;
/** /**

13
designer_base/src/com/fr/design/gui/icombobox/FRTreeComboBox.java

@ -57,6 +57,7 @@ public class FRTreeComboBox extends UIComboBox {
// richer:下拉展示用的tree // richer:下拉展示用的tree
protected JTree tree; protected JTree tree;
private boolean onlyLeafSelectable = true; private boolean onlyLeafSelectable = true;
private Object selectedObject = null;
public FRTreeComboBox() { public FRTreeComboBox() {
this(new JTree()); this(new JTree());
@ -162,6 +163,7 @@ public class FRTreeComboBox extends UIComboBox {
} }
public void setSelectedItem(Object o) { public void setSelectedItem(Object o) {
selectedObject = o;
if (o instanceof String) { if (o instanceof String) {
this.setSelectedItemString((String) o); this.setSelectedItemString((String) o);
return; return;
@ -173,6 +175,10 @@ public class FRTreeComboBox extends UIComboBox {
this.getModel().setSelectedItem(o); this.getModel().setSelectedItem(o);
} }
} }
public Object getSelectedItemObject() {
return selectedObject;
}
private boolean validTreePath(String treePath){ private boolean validTreePath(String treePath){
return StringUtils.isNotEmpty(treePath) && treePath.charAt(0) == '[' && treePath.endsWith("]"); return StringUtils.isNotEmpty(treePath) && treePath.charAt(0) == '[' && treePath.endsWith("]");
@ -183,12 +189,7 @@ public class FRTreeComboBox extends UIComboBox {
if (validTreePath(temp)) { if (validTreePath(temp)) {
temp = temp.substring(2, temp.length() - 1); temp = temp.substring(2, temp.length() - 1);
String[] selectedtable = temp.split(","); String[] selectedtable = temp.split(",");
String table = selectedtable[selectedtable.length - 1].trim(); return selectedtable[selectedtable.length - 1].trim();
if (table.contains(".")) {
String[] temp2 = table.split("\\.");
table = temp2[temp2.length - 1].trim();
}
return table;
} }
return ""; return "";
} }

7
designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java

@ -18,7 +18,7 @@ public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor {
@Override @Override
protected void showEditorPane() { protected void showEditorPane() {
choosePane = new BackgroundButtonPane(); choosePane = initBackgroundPane();
choosePane.setPreferredSize(new Dimension(600, 400)); choosePane.setPreferredSize(new Dimension(600, 400));
BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this)); BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this));
dlg.addDialogActionListener(new DialogActionAdapter() { dlg.addDialogActionListener(new DialogActionAdapter() {
@ -32,4 +32,9 @@ public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor {
choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground()); choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground());
dlg.setVisible(true); dlg.setVisible(true);
} }
protected BackgroundButtonPane initBackgroundPane(){
return new BackgroundButtonPane();
}
} }

39
designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java

@ -1,40 +1,17 @@
package com.fr.design.mainframe.widget.accessibles; package com.fr.design.mainframe.widget.accessibles;
import com.fr.base.background.ColorBackground; import com.fr.design.style.background.BackgroundButtonPane;
import com.fr.design.dialog.BasicDialog; import com.fr.design.style.background.BackgroundCardSwitchButtonPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper;
import com.fr.design.style.background.BackgroundTabPane;
import com.fr.general.Background;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
/** /**
* @author kerry * @author kerry
* @date 2018/1/17 * @date 2018/1/29
*/ */
public class AccessibleTabBackgroundEditor extends UneditableAccessibleEditor { public class AccessibleTabBackgroundEditor extends AccessibleImgBackgroundEditor {
private BackgroundTabPane choosePane;
public AccessibleTabBackgroundEditor() { public AccessibleTabBackgroundEditor() {
super(new BackgroundWrapper()); super();
} }
@Override @Override
protected void showEditorPane() { protected BackgroundButtonPane initBackgroundPane(){
choosePane = new BackgroundTabPane(); return new BackgroundCardSwitchButtonPane();
choosePane.setPreferredSize(new Dimension(600, 400));
BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this));
dlg.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
setValue(choosePane.update());
fireStateChanged();
}
});
choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground());
dlg.setVisible(true);
} }
} }

40
designer_base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java

@ -0,0 +1,40 @@
package com.fr.design.mainframe.widget.accessibles;
import com.fr.base.background.ColorBackground;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper;
import com.fr.design.style.background.BackgroundTabPane;
import com.fr.general.Background;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
/**
* @author kerry
* @date 2018/1/17
*/
public class AccessibleTabPaneBackgroundEditor extends UneditableAccessibleEditor {
private BackgroundTabPane choosePane;
public AccessibleTabPaneBackgroundEditor() {
super(new BackgroundWrapper());
}
@Override
protected void showEditorPane() {
choosePane = new BackgroundTabPane();
choosePane.setPreferredSize(new Dimension(600, 400));
BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this));
dlg.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
setValue(choosePane.update());
fireStateChanged();
}
});
choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground());
dlg.setVisible(true);
}
}

95
designer_base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java

@ -0,0 +1,95 @@
package com.fr.design.style.background;
import com.fr.base.background.ColorBackground;
import com.fr.base.background.GradientBackground;
import com.fr.base.background.ImageBackground;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.background.gradient.GradientBackgroundPane;
import com.fr.design.style.background.impl.ColorBackgroundPane;
import com.fr.design.style.background.impl.ImageBackgroundPane;
import com.fr.design.style.background.impl.NullBackgroundPane;
import com.fr.general.Background;
import com.fr.general.Inter;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @author kerry
* @date 2018/1/29
*/
public class BackgroundCardSwitchButtonPane extends BackgroundButtonPane {
private static Map<Class<? extends Background>, BackgroundUIWrapper> cardSwitchButton = new LinkedHashMap<>();
static {
registerCardSwitchBtnBackground(cardSwitchButton);
}
private static void registerCardSwitchBtnBackground(Map<Class<? extends Background>, BackgroundUIWrapper> map) {
map.put(ColorBackground.class, BackgroundUIWrapper.create()
.setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Color")));
map.put(ImageBackground.class, BackgroundUIWrapper.create()
.setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image")));
map.put(GradientBackground.class, BackgroundUIWrapper.create()
.setType(GradientBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Gradient_Color")));
}
public BackgroundCardSwitchButtonPane() {
super();
}
@Override
protected void initTabPane() {
int index = 0;
for (Class<? extends Background> key : cardSwitchButton.keySet()) {
BackgroundUIWrapper wrapper = cardSwitchButton.get(key);
wrapper.setIndex(index++);
tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane());
}
}
@Override
protected BackgroundUIWrapper getBackgroundUIWrapper(Background background) {
return cardSwitchButton.get(background == null ? null : background.getClass());
}
@Override
protected BackgroundDetailPane getTabItemPane(Background background, int index) {
BackgroundDetailPane quickPane = cacheMap.get(index);
if (quickPane == null) {
BackgroundUIWrapper uiWrapper = getBackgroundUIWrapper(background);
quickPane = BackgroundFactory.createByWrapper(uiWrapper);
quickPane.addChangeListener(backgroundChangeListener);
cacheMap.put(index, quickPane);
}
tabbedPane.setComponentAt(index, quickPane);
tabbedPane.setSelectedIndex(index);
return quickPane;
}
@Override
protected BackgroundDetailPane getTabItemPaneByIndex(int index) {
BackgroundDetailPane quickPane = cacheMap.get(index);
if (quickPane == null) {
quickPane = createDetailPaneByIndex(index);
tabbedPane.setComponentAt(index, quickPane);
cacheMap.put(index, quickPane);
quickPane.addChangeListener(backgroundChangeListener);
}
return quickPane;
}
public BackgroundDetailPane createDetailPaneByIndex(int index) {
for (BackgroundUIWrapper wrapper : cardSwitchButton.values()) {
if (wrapper.getIndex() == index) {
return BackgroundFactory.createByWrapper(wrapper);
}
}
return new NullBackgroundPane();
}
}

10
designer_base/src/com/fr/design/widget/component/BackgroundCompPane.java

@ -31,9 +31,7 @@ public abstract class BackgroundCompPane<T extends Widget> extends BasicPane {
public void initComponent() { public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
UILabel headLabel = createUILable(); UILabel headLabel = createUILable();
initalBackgroundEditor = new AccessibleImgBackgroundEditor(); initBackgroundEditor();
overBackgroundEditor = new AccessibleImgBackgroundEditor();
clickBackgroundEditor = new AccessibleImgBackgroundEditor();
String [] titles = new String[]{Inter.getLocText("FR-Designer_DEFAULT"), Inter.getLocText("FR-Designer_Custom")}; String [] titles = new String[]{Inter.getLocText("FR-Designer_DEFAULT"), Inter.getLocText("FR-Designer_Custom")};
double f = TableLayout.FILL; double f = TableLayout.FILL;
@ -57,6 +55,12 @@ public abstract class BackgroundCompPane<T extends Widget> extends BasicPane {
} }
protected void initBackgroundEditor(){
initalBackgroundEditor = new AccessibleImgBackgroundEditor();
overBackgroundEditor = new AccessibleImgBackgroundEditor();
clickBackgroundEditor = new AccessibleImgBackgroundEditor();
}
protected UILabel createUILable(){ protected UILabel createUILable(){
return new UILabel(Inter.getLocText("FR-Designer_Background")); return new UILabel(Inter.getLocText("FR-Designer_Background"));
} }

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

@ -1,7 +1,6 @@
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.background.ColorBackground;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
@ -151,9 +150,7 @@ public class XCardAddButton extends XButton{
CardSwitchButton titleButton = new CardSwitchButton(index,cardLayoutName); CardSwitchButton titleButton = new CardSwitchButton(index,cardLayoutName);
//设置标题 //设置标题
titleButton.setText(getTabTitleName()); titleButton.setText(getTabTitleName());
titleButton.setInitialBackground(ColorBackground.getInstance(Color.WHITE));
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);
this.tagLayout.setCurrentCard(titleButton); this.tagLayout.setCurrentCard(titleButton);

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

@ -5,7 +5,6 @@ package com.fr.design.designer.creator.cardlayout;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.background.ColorBackground;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
@ -34,9 +33,19 @@ import com.fr.general.Inter;
import com.fr.general.cardtag.TemplateStyle; import com.fr.general.cardtag.TemplateStyle;
import com.fr.stable.unit.PT; import com.fr.stable.unit.PT;
import javax.swing.*; 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 javax.swing.plaf.basic.BasicLabelUI;
import java.awt.*; 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.event.MouseEvent;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.ArrayList; import java.util.ArrayList;
@ -62,11 +71,8 @@ public class XCardSwitchButton extends XButton {
private static final int MIN_SIZE = 1; private static final int MIN_SIZE = 1;
// 删除按钮识别区域偏移量 // 删除按钮识别区域偏移量
private static final int RIGHT_OFFSET = 15; private static final int CLOSE_ICON_RIGHT_OFFSET = 15;
private static final int TOP_OFFSET = 15; private static final int CLOSE_ICON_TOP_OFFSET = 15;
//这边先不计算button的高度,涉及到layout那边的整体高度,先用之前的固定高度
private static final int DEFAULT_BUTTON_HEIGHT = 36;
// tab按钮里的字体因为按钮内部的布局看起来比正常的要小,加个调整量 // tab按钮里的字体因为按钮内部的布局看起来比正常的要小,加个调整量
private static final int FONT_SIZE_ADJUST = 2; private static final int FONT_SIZE_ADJUST = 2;
@ -74,13 +80,12 @@ public class XCardSwitchButton extends XButton {
//文字竖排时用来计算文字大小 //文字竖排时用来计算文字大小
private static final int RESLUTION = 120; private static final int RESLUTION = 120;
private static final int DOTSLINESPACE = 6;
private XWCardLayout cardLayout; private XWCardLayout cardLayout;
private XWCardTagLayout tagLayout; private XWCardTagLayout tagLayout;
private Background selectBackground; private Background selectBackground;
private boolean isCustomStyle;
private UILabel label; private UILabel label;
private Icon closeIcon = MOUSE_CLOSE; private Icon closeIcon = MOUSE_CLOSE;
@ -101,14 +106,6 @@ 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() { public Background getSelectBackground() {
return selectBackground; return selectBackground;
} }
@ -157,8 +154,7 @@ public class XCardSwitchButton extends XButton {
} }
//获取当前tab的index //获取当前tab的index
XCardSwitchButton button = this; CardSwitchButton currentButton = (CardSwitchButton) this.toData();
CardSwitchButton currentButton = (CardSwitchButton) button.toData();
int index = currentButton.getIndex(); int index = currentButton.getIndex();
int maxIndex = cardLayout.getComponentCount() - 1; int maxIndex = cardLayout.getComponentCount() - 1;
@ -169,14 +165,13 @@ public class XCardSwitchButton extends XButton {
deleteTabLayout(selectionModel, designer); deleteTabLayout(selectionModel, designer);
return; return;
} }
deleteCard(button,index); deleteCard(this, index);
this.tagLayout.adjustComponentWidth();
designer.fireTargetModified(); designer.fireTargetModified();
LayoutUtils.layoutRootContainer(designer.getRootComponent()); LayoutUtils.layoutRootContainer(designer.getRootComponent());
FormHierarchyTreePane.getInstance().refreshRoot(); FormHierarchyTreePane.getInstance().refreshRoot();
return; return;
} }
//将当前tab按钮改为选中状态 //将当前tab按钮改为选中状态
changeButtonState(index); changeButtonState(index);
@ -222,7 +217,7 @@ public class XCardSwitchButton extends XButton {
} }
//删除card,同时修改其他switchbutton和tabfit的index //删除card,同时修改其他switchbutton和tabfit的index
private void deleteCard(XCardSwitchButton button,int index){ private void deleteCard(XCardSwitchButton button, int index){
String titleName = button.getContentLabel().getText(); String titleName = button.getContentLabel().getText();
int value = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer_ConfirmDialog_Content") + "“" + titleName + "”", int value = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer_ConfirmDialog_Content") + "“" + titleName + "”",
Inter.getLocText("FR-Designer_ConfirmDialog_Title"), JOptionPane.YES_NO_OPTION); Inter.getLocText("FR-Designer_ConfirmDialog_Title"), JOptionPane.YES_NO_OPTION);
@ -292,18 +287,18 @@ public class XCardSwitchButton extends XButton {
int width = button.getWidth(); int width = button.getWidth();
// 鼠标进入按钮右侧删除图标区域 // 鼠标进入按钮右侧删除图标区域
double recX = position.getX() + titlePoint.getX() + (width - RIGHT_OFFSET); double recX = position.getX() + titlePoint.getX() + (width - CLOSE_ICON_RIGHT_OFFSET);
double recY = position.getY() + titlePoint.getY() + TOP_OFFSET; double recY = position.getY() + titlePoint.getY() + CLOSE_ICON_TOP_OFFSET;
return (recX < ex && ex < recX + RIGHT_OFFSET && ey < recY && ey > position.getY()); return (recX < ex && ex < recX + CLOSE_ICON_RIGHT_OFFSET && ey < recY && ey > position.getY());
} }
//将当前switchButton改为选中状态 //将当前switchButton改为选中状态
private void changeButtonState(int index){ private void changeButtonState(int index) {
for(int i=0;i<this.tagLayout.getComponentCount();i++){ for (int i = 0; i < this.tagLayout.getComponentCount(); i++) {
XCardSwitchButton temp = (XCardSwitchButton) tagLayout.getComponent(i); XCardSwitchButton temp = (XCardSwitchButton) tagLayout.getComponent(i);
CardSwitchButton tempButton = (CardSwitchButton) temp.toData(); CardSwitchButton tempButton = (CardSwitchButton) temp.toData();
tempButton.setShowButton(tempButton.getIndex()==index); tempButton.setShowButton(tempButton.getIndex() == index);
} }
} }
@ -311,8 +306,10 @@ public class XCardSwitchButton extends XButton {
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
drawBackground(); CardSwitchButton button = (CardSwitchButton) this.toData();
drawTitle(); WidgetTitle widgetTitle = getWidgetTitle();
drawBackground(button, widgetTitle);
drawTitle(button, widgetTitle);
Dimension panelSize = this.getContentLabel().getSize(); Dimension panelSize = this.getContentLabel().getSize();
this.getContentBackground().paint(g, new Rectangle2D.Double(0, 0, panelSize.getWidth(), panelSize.getHeight())); this.getContentBackground().paint(g, new Rectangle2D.Double(0, 0, panelSize.getWidth(), panelSize.getHeight()));
drawCloseIcon(g2d); drawCloseIcon(g2d);
@ -320,62 +317,41 @@ public class XCardSwitchButton extends XButton {
//画删除图标 //画删除图标
private void drawCloseIcon(Graphics2D g2d){ private void drawCloseIcon(Graphics2D g2d){
closeIcon.paintIcon(this, g2d,this.getWidth()-LEFT_GAP,0); closeIcon.paintIcon(this, g2d, this.getWidth() - LEFT_GAP, 0);
} }
//画背景 //画背景
private void drawBackground(){ private void drawBackground(CardSwitchButton button, WidgetTitle widgetTitle){
CardSwitchButton button = (CardSwitchButton)this.toData(); Background background = widgetTitle.getBackground();
Background currentBackground; TemplateStyle templateStyle = ((WCardTagLayout) tagLayout.toData()).getTemplateStyle();
currentBackground = this.getSelectBackground(); Background initialBackground = button.getInitialBackground();
//这边就是button的背景图片,图片的是image,默认的是color,所以不应该是针对null的判断 Background defaultSelectBackground = templateStyle.getSelectBackground();
String type = currentBackground != null? currentBackground.getBackgroundType() : DEFAULT_TYPE; //todo 这边先这么改,之后会加一个选中背景设置再做调整
if (type.equals(COLOR_BACKGROUND_TYPE) || type.equals(DEFAULT_TYPE)) { if (button.isShowButton()) {
ColorBackground background; this.setContentBackground(defaultSelectBackground);
if(button.isShowButton()){ } else {
this.rebuid(); this.setContentBackground(initialBackground == null ? background : initialBackground);
background = ColorBackground.getInstance(CHOOSED_GRAL);
this.setContentBackground(background);
}else{
this.rebuid();
background = ColorBackground.getInstance(NORMAL_GRAL);
this.setContentBackground(background);
}
} }
} }
//画标题 //画标题
private void drawTitle() { private void drawTitle(CardSwitchButton button, WidgetTitle widgetTitle) {
CardSwitchButton button = (CardSwitchButton) this.toData();
String titleText = button.getText(); String titleText = button.getText();
this.setButtonText(titleText); this.setButtonText(titleText);
if (this.cardLayout == null) { FRFont font = widgetTitle.getFrFont();
initRelateLayout();
}
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); FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(),font.getSize() + FONT_SIZE_ADJUST);
UILabel label = this.getContentLabel(); UILabel label = this.getContentLabel();
label.setFont(newFont); label.setFont(newFont);
label.setForeground(font.getForeground()); label.setForeground(font.getForeground());
Background background = title.getBackground();
TemplateStyle templateStyle = ((WCardTagLayout)tagLayout.toData()).getTemplateStyle(); }
Background selectBackground = templateStyle.getSelectBackground();
if (background != null) { private WidgetTitle getWidgetTitle() {
if(button.isShowButton() && selectBackground != null){ if (this.cardLayout == null) {
this.setContentBackground(selectBackground); initRelateLayout();
}else if (button.isShowButton() && selectBackground == null){
background = ColorBackground.getInstance(CHOOSED_GRAL);
this.setContentBackground(background);
} else {
this.setContentBackground(background);
}
} }
LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle();
return style.getTitle();
} }
//删除tab布局 //删除tab布局
@ -444,71 +420,77 @@ public class XCardSwitchButton extends XButton {
return new CardSwitchBtnLabel(); return new CardSwitchBtnLabel();
} }
public class CardSwitchBtnLabel extends UILabel{ public class CardSwitchBtnLabel extends UILabel {
public CardSwitchBtnLabel(){
updateUI(); public CardSwitchBtnLabel() {
updateUI();
}
@Override
public void updateUI() {
setUI(new CardSwitchBtnLabelUI());
} }
@Override
public void updateUI() {
setUI(new CardSwitchBtnLabelUI());
}
} }
public class CardSwitchBtnLabelUI extends BasicLabelUI{ public class CardSwitchBtnLabelUI extends BasicLabelUI {
private static final int DOT_COUNT = 3;
@Override private static final String DOT = ".";
public void paint(Graphics g, JComponent c) private static final int DOTS_LINESPACE = 6;
{ private static final int DOTS_HEIGHT = 10;
Graphics2D g2d = (Graphics2D)g;
CardSwitchButton button = (CardSwitchButton) XCardSwitchButton.this.toData(); @Override
int width = XCardSwitchButton.this.getWidth(); public void paint(Graphics g, JComponent c) {
int height= XCardSwitchButton.this.getHeight(); WCardTagLayout wCardTagLayout = (WCardTagLayout) tagLayout.toData();
String titleText = button.getText(); if (ComparatorUtils.equals(wCardTagLayout.getTextDirection(), WTabTextDirection.TEXT_VER_DIRECTION)) {
LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); //绘制文本竖排展示
WidgetTitle title = style.getTitle(); paintVerticalText(g);
FRFont font = title.getFrFont(); } else {
FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(),font.getSize() + FONT_SIZE_ADJUST); super.paint(g, c);
FontMetrics fm = GraphHelper.getFontMetrics(newFont); }
}
WCardTagLayout wCardTagLayout = (WCardTagLayout) tagLayout.toData();
StringBuilder titleStringBuf = new StringBuilder(); private void paintVerticalText(Graphics g) {
//竖向处理 Graphics2D g2d = (Graphics2D) g;
if(ComparatorUtils.equals(wCardTagLayout.getTextDirection(), WTabTextDirection.TEXT_VER_DIRECTION)){ int width = XCardSwitchButton.this.getWidth();
java.util.List verticalTextList = new ArrayList(); int height = XCardSwitchButton.this.getHeight();
for (int i = 0; i < titleText.length(); i++) { CardSwitchButton button = (CardSwitchButton) XCardSwitchButton.this.toData();
titleStringBuf.append(titleText.charAt(i)); String titleText = button.getText();
verticalTextList.add(titleStringBuf.substring(0, titleStringBuf.length())); java.util.List verticalTextList = new ArrayList();
titleStringBuf.delete(0, titleStringBuf.length()); StringBuilder titleStringBuf = new StringBuilder();
} WidgetTitle title = getWidgetTitle();
int textAscent = fm.getAscent(); FRFont font = title.getFrFont();
int textHeight = fm.getHeight(); FRFont newFont = FRFont.getInstance(font.getName(), font.getStyle(), font.getSize() + FONT_SIZE_ADJUST);
int textY = 0; FontMetrics fm = GraphHelper.getFontMetrics(newFont);
textY += textAscent; for (int i = 0; i < titleText.length(); i++) {
for (int i = 0; i < verticalTextList.size(); i++) { titleStringBuf.append(titleText.charAt(i));
String paint_str = (String) verticalTextList.get(i); verticalTextList.add(titleStringBuf.substring(0, titleStringBuf.length()));
titleStringBuf.delete(0, titleStringBuf.length());
GraphHelper.drawString(g2d, paint_str, (width - fm.stringWidth(paint_str)) / 2, textY); }
textY += textHeight; int textAscent = fm.getAscent();
textY += PT.pt2pix(0, RESLUTION); int textHeight = fm.getHeight();
if (textY > height - textHeight && i < verticalTextList.size()-1) { int textY = 0;
textY -= 10; textY += textAscent;
paintDots(g2d, textY, (width - fm.stringWidth(paint_str)) / 2); for (int i = 0; i < verticalTextList.size(); i++) {
break; String paint_str = (String) verticalTextList.get(i);
}
} GraphHelper.drawString(g2d, paint_str, (width - fm.stringWidth(paint_str)) / 2, textY);
}else{ textY += textHeight;
super.paint(g, c); textY += PT.pt2pix(0, RESLUTION);
} if (textY > height - textHeight && i < verticalTextList.size() - 1) {
} textY -= DOTS_HEIGHT;
paintDots(g2d, textY, (width - fm.stringWidth(paint_str)) / 2);
public void paintDots(Graphics2D g2d, int startY, int startX){ break;
for (int i = 0; i < 3; i++) { }
String paint_str = "."; }
GraphHelper.drawString(g2d, paint_str, startX, startY); }
startY += DOTSLINESPACE;//
startY += PT.pt2pix(0, RESLUTION); public void paintDots(Graphics2D g2d, int startY, int startX) {
} for (int i = 0; i < DOT_COUNT; i++) {
} GraphHelper.drawString(g2d, DOT, startX, startY);
startY += DOTS_LINESPACE;
startY += PT.pt2pix(0, RESLUTION);
}
}
} }
} }

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

@ -31,7 +31,6 @@ import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WCardTitleLayout; 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.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
@ -227,12 +226,9 @@ public class XWCardLayout extends XLayoutContainer {
private XCardSwitchButton initFirstButton(String widgetName, XWCardTagLayout xTag){ private XCardSwitchButton initFirstButton(String widgetName, XWCardTagLayout xTag){
CardSwitchButton firstBtn = new CardSwitchButton(widgetName); CardSwitchButton firstBtn = new CardSwitchButton(widgetName);
firstBtn.setText(Inter.getLocText("FR-Designer_Title") + 0); firstBtn.setText(Inter.getLocText("FR-Designer_Title") + 0);
firstBtn.setInitialBackground(ColorBackground.getInstance(Color.WHITE));
firstBtn.setCustomStyle(true);
xTag.setCurrentCard(firstBtn); xTag.setCurrentCard(firstBtn);
XCardSwitchButton xFirstBtn = new XCardSwitchButton(firstBtn, new Dimension(CardSwitchButton.DEF_WIDTH, -1), this, xTag); XCardSwitchButton xFirstBtn = new XCardSwitchButton(firstBtn, new Dimension(CardSwitchButton.DEF_WIDTH, -1), this, xTag);
xFirstBtn.setBackupParent(xTag); xFirstBtn.setBackupParent(xTag);
return xFirstBtn; return xFirstBtn;
} }

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

@ -1,7 +1,6 @@
package com.fr.design.designer.creator.cardlayout; package com.fr.design.designer.creator.cardlayout;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
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;
@ -22,7 +21,6 @@ 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.Background;
import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
@ -213,40 +211,27 @@ public class XWTabFitLayout extends XWFitLayout {
} }
private void checkButonType() { private void checkButonType() {
if (this.xCardSwitchButton == null) { WTabFitLayout wTabFitLayout = ((WTabFitLayout) data);
//假如为空,默认获取第一个tab的cardBtn属性
try {
xCardSwitchButton = (XCardSwitchButton) ((XWCardMainBorderLayout) this.getTopLayout()).getTitlePart().getTagPart().getComponent(0);
}catch (Exception e){
FRLogger.getLogger().error(e.getMessage());
}
return;
}
boolean isStyle = ((WTabFitLayout) data).isCustomStyle();
Background bg;
bg = ColorBackground.getInstance(NORMAL_GRAL);
CardSwitchButton cardSwitchButton = (CardSwitchButton) this.xCardSwitchButton.toData(); CardSwitchButton cardSwitchButton = (CardSwitchButton) this.xCardSwitchButton.toData();
boolean isStyle = wTabFitLayout.isCustomStyle();
Background initialBackground = wTabFitLayout.getInitialBackground();
Background overBackground = wTabFitLayout.getOverBackground();
Background clickBackground = wTabFitLayout.getClickBackground();
if (!isStyle) { if (!isStyle) {
this.xCardSwitchButton.setCustomStyle(false); cardSwitchButton.setCustomStyle(false);
this.xCardSwitchButton.setSelectBackground(bg);
cardSwitchButton.setInitialBackground(null); cardSwitchButton.setInitialBackground(null);
cardSwitchButton.setClickBackground(null); cardSwitchButton.setClickBackground(null);
cardSwitchButton.setOverBackground(null); cardSwitchButton.setOverBackground(null);
} else { } else {
Background initialBackground = cardSwitchButton.getInitialBackground();
bg = initialBackground == null ? bg : initialBackground;
this.xCardSwitchButton.setSelectBackground(bg);
this.xCardSwitchButton.setCustomStyle(true);
cardSwitchButton.setCustomStyle(true); cardSwitchButton.setCustomStyle(true);
if (this.initialBackground != null){ if (initialBackground != null){
this.xCardSwitchButton.setSelectBackground(this.initialBackground); cardSwitchButton.setInitialBackground(initialBackground);
cardSwitchButton.setInitialBackground(this.initialBackground);
} }
if (this.overBackground != null){ if (overBackground != null){
cardSwitchButton.setOverBackground(this.overBackground); cardSwitchButton.setOverBackground(overBackground);
} }
if (this.clickBackground != null) { if (clickBackground != null) {
cardSwitchButton.setClickBackground(this.clickBackground); cardSwitchButton.setClickBackground(clickBackground);
} }
} }
} }
@ -601,30 +586,14 @@ public class XWTabFitLayout extends XWFitLayout {
@Override @Override
public void firePropertyChange(){ public void firePropertyChange(){
checkButonType();
//根据字体长度设置tab宽度 //根据字体长度设置tab宽度
setCardSwitchBtnSize(); setCardSwitchBtnSize();
XWCardLayout cardLayout = (XWCardLayout) this.getBackupParent(); XWCardLayout cardLayout = (XWCardLayout) this.getBackupParent();
XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) cardLayout.getBackupParent(); XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) cardLayout.getBackupParent();
XWCardTitleLayout titleLayout = mainLayout.getTitlePart(); XWCardTitleLayout titleLayout = mainLayout.getTitlePart();
// //放置tab按钮的tagLayout //放置tab按钮的tagLayout
XWCardTagLayout tagLayout = titleLayout.getTagPart(); XWCardTagLayout tagLayout = titleLayout.getTagPart();
tagLayout.setTabsAndAdjust(); tagLayout.setTabsAndAdjust();
initialBackground = ((WTabFitLayout) data).getInitialBackground();
overBackground = ((WTabFitLayout) data).getOverBackground();
clickBackground = ((WTabFitLayout)data).getClickBackground();
CardSwitchButton cardSwitchButton = (CardSwitchButton) xCardSwitchButton.toData();
if(initialBackground != null){
xCardSwitchButton.setSelectBackground(initialBackground);
cardSwitchButton.setInitialBackground(initialBackground);
}
if(overBackground != null){
cardSwitchButton.setOverBackground(overBackground);
}
if(clickBackground != null){
cardSwitchButton.setClickBackground(clickBackground);
}
} }
public void setCardSwitchBtnSize(){ public void setCardSwitchBtnSize(){

5
designer_form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPreviewPane.java

@ -11,4 +11,9 @@ public class CardTagLayoutBorderPreviewPane extends LayoutBorderPreviewPane{
public CardTagLayoutBorderPreviewPane(LayoutBorderStyle borderStyle) { public CardTagLayoutBorderPreviewPane(LayoutBorderStyle borderStyle) {
super(borderStyle,true); super(borderStyle,true);
} }
@Override
protected void showTitlePreviewPane(){
}
} }

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

@ -92,9 +92,14 @@ public class LayoutBorderPreviewPane extends JPanel{
jp.setBounds(smallGAP,smallGAP, getWidth() - GAP, height); jp.setBounds(smallGAP,smallGAP, getWidth() - GAP, height);
borderStyle.paint(g, new Rectangle2D.Double(smallGAP, smallGAP, getWidth() - GAP, getHeight() - GAP)); borderStyle.paint(g, new Rectangle2D.Double(smallGAP, smallGAP, getWidth() - GAP, getHeight() - GAP));
jp.setFontObject(borderStyle.getTitle().getFrFont()); jp.setFontObject(borderStyle.getTitle().getFrFont());
showTitlePreviewPane();
} }
} }
protected void showTitlePreviewPane(){
jp.setVisible(borderStyle.getType() == LayoutBorderStyle.TITLE);
}
private class titlePreviewPane extends UITextArea { private class titlePreviewPane extends UITextArea {
private FRFont frFont = null; private FRFont frFont = null;

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

@ -20,6 +20,8 @@ import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Point; import java.awt.Point;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
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;
@ -56,6 +58,12 @@ public class ComponentTree extends JTree {
ComponetTreeMouseListener componetTreeMouseListener = new ComponetTreeMouseListener(this); ComponetTreeMouseListener componetTreeMouseListener = new ComponetTreeMouseListener(this);
this.addMouseMotionListener(componetTreeMouseListener); this.addMouseMotionListener(componetTreeMouseListener);
this.addMouseListener(componetTreeMouseListener); this.addMouseListener(componetTreeMouseListener);
this.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
designer.dispatchEvent(e);
}
});
} }
public FormDesigner getDesigner() { public FormDesigner getDesigner() {

37
designer_form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java

@ -1,7 +1,9 @@
package com.fr.design.widget.ui.designer.component; package com.fr.design.widget.ui.designer.component;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.widget.accessibles.AccessibleTabBackgroundEditor;
import com.fr.design.widget.component.BackgroundCompPane; import com.fr.design.widget.component.BackgroundCompPane;
import com.fr.form.ui.CardSwitchButton;
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.Background;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -15,33 +17,40 @@ public class TabFitLayoutBackgroundPane extends BackgroundCompPane<WTabFitLayout
} }
public void update(WTabFitLayout wTabFitLayout){ @Override
protected void initBackgroundEditor(){
initalBackgroundEditor = new AccessibleTabBackgroundEditor();
overBackgroundEditor = new AccessibleTabBackgroundEditor();
clickBackgroundEditor = new AccessibleTabBackgroundEditor();
}
public void update(CardSwitchButton cardSwitchButton){
int selectIndex = backgroundHead.getSelectedIndex(); int selectIndex = backgroundHead.getSelectedIndex();
if(selectIndex == 0){ if(selectIndex == 0){
wTabFitLayout.setCustomStyle(false); cardSwitchButton.setCustomStyle(false);
wTabFitLayout.setInitialBackground(null); cardSwitchButton.setInitialBackground(null);
wTabFitLayout.setOverBackground(null); cardSwitchButton.setOverBackground(null);
wTabFitLayout.setClickBackground(null); cardSwitchButton.setClickBackground(null);
}else{ }else{
wTabFitLayout.setCustomStyle(true); cardSwitchButton.setCustomStyle(true);
wTabFitLayout.setInitialBackground((Background) initalBackgroundEditor.getValue()); cardSwitchButton.setInitialBackground((Background) initalBackgroundEditor.getValue());
wTabFitLayout.setOverBackground((Background) overBackgroundEditor.getValue()); cardSwitchButton.setOverBackground((Background) overBackgroundEditor.getValue());
wTabFitLayout.setClickBackground((Background)clickBackgroundEditor.getValue()); cardSwitchButton.setClickBackground((Background)clickBackgroundEditor.getValue());
} }
switchCard(); switchCard();
} }
public void populate(WTabFitLayout wTabFitLayout){ public void populate(CardSwitchButton cardSwitchButton){
if(!wTabFitLayout.isCustomStyle()){ if(!cardSwitchButton.isCustomStyle()){
backgroundHead.setSelectedIndex(0); backgroundHead.setSelectedIndex(0);
initalBackgroundEditor.setValue(null); initalBackgroundEditor.setValue(null);
overBackgroundEditor.setValue(null); overBackgroundEditor.setValue(null);
clickBackgroundEditor.setValue(null); clickBackgroundEditor.setValue(null);
}else{ }else{
backgroundHead.setSelectedIndex(1); backgroundHead.setSelectedIndex(1);
initalBackgroundEditor.setValue(wTabFitLayout.getInitialBackground()); initalBackgroundEditor.setValue(cardSwitchButton.getInitialBackground());
overBackgroundEditor.setValue(wTabFitLayout.getOverBackground()); overBackgroundEditor.setValue(cardSwitchButton.getOverBackground());
clickBackgroundEditor.setValue(wTabFitLayout.getClickBackground()); clickBackgroundEditor.setValue(cardSwitchButton.getClickBackground());
} }
switchCard(); switchCard();
} }

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

@ -2,8 +2,6 @@ package com.fr.design.widget.ui.designer.layout;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator; 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.foldablepane.UIExpandablePane;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
@ -15,8 +13,6 @@ import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; 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 com.fr.general.Inter;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -56,7 +52,7 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBord
setCarousel = new UICheckBox(Inter.getLocText("FR-Designer_setCarousel")); setCarousel = new UICheckBox(Inter.getLocText("FR-Designer_setCarousel"));
IntervalPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{ IntervalPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{
new UILabel(Inter.getLocText("FR-Designer_carouselInterval")), carouselInterval}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); new UILabel(Inter.getLocText("FR-Designer_carouselInterval")), carouselInterval}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
IntervalPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); IntervalPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L5, IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L6));
jPanel.add(setCarousel, BorderLayout.NORTH); jPanel.add(setCarousel, BorderLayout.NORTH);
jPanel.add(IntervalPane, BorderLayout.CENTER); jPanel.add(IntervalPane, BorderLayout.CENTER);
setCarousel.addActionListener(new ActionListener() { setCarousel.addActionListener(new ActionListener() {

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

@ -1,8 +1,10 @@
package com.fr.design.widget.ui.designer.layout; package com.fr.design.widget.ui.designer.layout;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.mainframe.widget.accessibles.AccessibleTabBackgroundEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleTabPaneBackgroundEditor;
import com.fr.form.ui.CardSwitchButton;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.cardtag.DefaultTemplateStyle;
import com.fr.general.cardtag.TemplateStyle; import com.fr.general.cardtag.TemplateStyle;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
@ -35,7 +37,7 @@ import java.awt.Component;
* Created by kerry on 2017/11/16. * Created by kerry on 2017/11/16.
*/ */
public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout> { public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout> {
private AccessibleTabBackgroundEditor backgroundEditor; private AccessibleTabPaneBackgroundEditor backgroundEditor;
private FRFontPane frFontPane; private FRFontPane frFontPane;
private UIButtonGroup displayPositionGroup; private UIButtonGroup displayPositionGroup;
private UIButtonGroup textDirectionGroup; private UIButtonGroup textDirectionGroup;
@ -49,7 +51,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
public void initComponent() { public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
backgroundEditor = new AccessibleTabBackgroundEditor(); backgroundEditor = new AccessibleTabPaneBackgroundEditor();
templateStyleEditor = new AccessibleTemplateStyleEditor(); templateStyleEditor = new AccessibleTemplateStyleEditor();
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
@ -59,7 +61,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
UILabel fontLabel = new UILabel(Inter.getLocText("FR-Designer_Font")); UILabel fontLabel = new UILabel(Inter.getLocText("FR-Designer_Font"));
fontLabel.setVerticalAlignment(SwingConstants.TOP); fontLabel.setVerticalAlignment(SwingConstants.TOP);
frFontPane = new FRFontPane(){ frFontPane = new FRFontPane() {
protected JPanel createRightPane() { protected JPanel createRightPane() {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
@ -73,7 +75,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
} }
}; };
displayPositionGroup = new UIButtonGroup(WTabDisplayPosition.getStringArray()){ displayPositionGroup = new UIButtonGroup(WTabDisplayPosition.getStringArray()) {
@Override @Override
public boolean shouldResponseNameListener() { public boolean shouldResponseNameListener() {
return true; return true;
@ -105,7 +107,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
public void populateBean(WCardTagLayout ob) { public void populateBean(WCardTagLayout ob) {
//标题背景和字体属性设置在WCardLayout上做兼容 //标题背景和字体属性设置在WCardLayout上做兼容
XLayoutContainer topLayout = creator.getTopLayout(); XLayoutContainer topLayout = creator.getTopLayout();
LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout)topLayout).getCardPart().toData().getBorderStyle(); LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout) topLayout).getCardPart().toData().getBorderStyle();
displayPositionGroup.setSelectedIndex(ob.getDisplayPosition().getType()); displayPositionGroup.setSelectedIndex(ob.getDisplayPosition().getType());
textDirectionGroup.setSelectedIndex(ob.getTextDirection().getType()); textDirectionGroup.setSelectedIndex(ob.getTextDirection().getType());
@ -121,25 +123,41 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout>
public WCardTagLayout updateBean() { public WCardTagLayout updateBean() {
//标题背景和字体属性设置在WCardLayout上做兼容 //标题背景和字体属性设置在WCardLayout上做兼容
XLayoutContainer topLayout = creator.getTopLayout(); XLayoutContainer topLayout = creator.getTopLayout();
LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout)topLayout).getCardPart().toData().getBorderStyle(); LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout) topLayout).getCardPart().toData().getBorderStyle();
FRFont frFont = layoutBorderStyle.getTitle().getFrFont() == null ? FRFont.getInstance() : layoutBorderStyle.getTitle().getFrFont(); FRFont frFont = layoutBorderStyle.getTitle().getFrFont() == null ? FRFont.getInstance() : layoutBorderStyle.getTitle().getFrFont();
layoutBorderStyle.getTitle().setFrFont(frFontPane.update(frFont)); layoutBorderStyle.getTitle().setFrFont(frFontPane.update(frFont));
WCardTagLayout layout = (WCardTagLayout) creator.toData(); WCardTagLayout layout = (WCardTagLayout) creator.toData();
boolean isHori = displayPositionGroup.getSelectedIndex() == WTabDisplayPosition.TOP_POSITION.getType() || displayPositionGroup.getSelectedIndex() == WTabDisplayPosition.BOTTOM_POSITION.getType(); 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"))){ if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Tab_Style_Template"))) {
layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex())); layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex()));
textDirectionGroup.setSelectedIndex(isHori? WTabTextDirection.TEXT_HORI_DERECTION.getType():WTabTextDirection.TEXT_VER_DIRECTION.getType()); textDirectionGroup.setSelectedIndex(isHori ? WTabTextDirection.TEXT_HORI_DERECTION.getType() : WTabTextDirection.TEXT_VER_DIRECTION.getType());
layout.setHgap(isHori ? WCardTagLayout.DESIGNER_DEFAULT_GAP : 0);
layout.setVgap(isHori ? 0 : WCardTagLayout.DESIGNER_DEFAULT_GAP);
} }
layout.setTextDirection(WTabTextDirection.parse(textDirectionGroup.getSelectedIndex())); layout.setTextDirection(WTabTextDirection.parse(textDirectionGroup.getSelectedIndex()));
TemplateStyle templateStyle = (TemplateStyle) templateStyleEditor.getValue(); TemplateStyle templateStyle = (TemplateStyle) templateStyleEditor.getValue();
if(!ComparatorUtils.equals(layout.getTemplateStyle(), templateStyle)){ if (!ComparatorUtils.equals(layout.getTemplateStyle(), templateStyle)) {
backgroundEditor.setValue(templateStyle.getDefaultBackground()); backgroundEditor.setValue(templateStyle.getDefaultBackground());
layoutBorderStyle.getTitle().setBackground(templateStyle.getDefaultBackground()); layoutBorderStyle.getTitle().setBackground(templateStyle.getDefaultBackground());
//重置内部tab的默认背景
resetTabBackground(layout, templateStyle);
layout.setTemplateStyle(templateStyle); layout.setTemplateStyle(templateStyle);
}else{ } else {
layoutBorderStyle.getTitle().setBackground((Background) backgroundEditor.getValue()); layoutBorderStyle.getTitle().setBackground((Background) backgroundEditor.getValue());
} }
return layout; return layout;
} }
private void resetTabBackground(WCardTagLayout layout, TemplateStyle templateStyle) {
for (int i = 0, len = layout.getWidgetCount(); i < len; i++) {
CardSwitchButton button = layout.getSwitchButton(i);
//兼容默认样式
boolean defaultStyle = ComparatorUtils.equals(templateStyle.getStyle(), DefaultTemplateStyle.DEFAULT_TEMPLATE_STYLE);
button.setInitialBackground(defaultStyle ? null : templateStyle.getTabDefaultBackground());
button.setOverBackground(null);
button.setClickBackground(null);
button.setCustomStyle(true);
}
}
} }

4
designer_form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java

@ -78,12 +78,12 @@ public class WTabFitLayoutDefinePane extends AbstractDataModify<WTabFitLayout> {
@Override @Override
public void populateBean(WTabFitLayout ob) { public void populateBean(WTabFitLayout ob) {
borderStyle.populate(ob);
paddingBoundPane.populate(ob); paddingBoundPane.populate(ob);
componentInterval.setValue(ob.getCompInterval()); componentInterval.setValue(ob.getCompInterval());
if(ob.getCurrentCard() == null){ if(ob.getCurrentCard() == null){
ob.setCurrentCard(getRelateSwitchButton(ob)); ob.setCurrentCard(getRelateSwitchButton(ob));
} }
borderStyle.populate(ob.getCurrentCard());
titleField.setText(ob.getCurrentCard().getText()); titleField.setText(ob.getCurrentCard().getText());
} }
@ -118,7 +118,7 @@ public class WTabFitLayoutDefinePane extends AbstractDataModify<WTabFitLayout> {
@Override @Override
public WTabFitLayout updateBean() { public WTabFitLayout updateBean() {
WTabFitLayout layout = (WTabFitLayout) creator.toData(); WTabFitLayout layout = (WTabFitLayout) creator.toData();
borderStyle.update(layout); borderStyle.update(layout.getCurrentCard());
if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Layout-Padding"))) { if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Layout-Padding"))) {
paddingBoundPane.update(layout); paddingBoundPane.update(layout);
} }

Loading…
Cancel
Save