plough
7 years ago
53 changed files with 2137 additions and 607 deletions
@ -0,0 +1,274 @@ |
|||||||
|
package com.fr.design.gui.imenu; |
||||||
|
|
||||||
|
import com.fr.design.constants.UIConstants; |
||||||
|
import com.fr.design.utils.gui.GUIPaintUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.border.Border; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
public class UIHeadMenu extends UIMenu { |
||||||
|
private static final float REC = 8f; |
||||||
|
private JPopupMenu popupMenu; |
||||||
|
|
||||||
|
public UIHeadMenu(String name) { |
||||||
|
super(name); |
||||||
|
} |
||||||
|
|
||||||
|
public JPopupMenu getPopupMenu() { |
||||||
|
ensurePopupMenuCreated(); |
||||||
|
popupMenu.setBackground(UIConstants.NORMAL_BACKGROUND); |
||||||
|
popupMenu.setBorder(new Border() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { |
||||||
|
Graphics2D g2d = (Graphics2D) g; |
||||||
|
int rec = (int) REC; |
||||||
|
GUIPaintUtils.paintShapeBorder(g2d, x, y, width, height, rec); |
||||||
|
if (!(UIHeadMenu.this.getParent() instanceof JPopupMenu)) { |
||||||
|
g.setColor(UIConstants.NORMAL_BACKGROUND); |
||||||
|
g.drawLine(1, 0, UIHeadMenu.this.getWidth() - 2, 0); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isBorderOpaque() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Insets getBorderInsets(Component c) { |
||||||
|
return new Insets(5, 2, 10, 10); |
||||||
|
} |
||||||
|
}); |
||||||
|
return popupMenu; |
||||||
|
} |
||||||
|
|
||||||
|
protected void ensurePopupMenuCreated() { |
||||||
|
if (popupMenu == null) { |
||||||
|
this.popupMenu = new JPopupMenu() { |
||||||
|
@Override |
||||||
|
protected void paintComponent(Graphics g) { |
||||||
|
Graphics2D g2d = (Graphics2D) g; |
||||||
|
float wdith = getWidth(); |
||||||
|
float heigth = getHeight(); |
||||||
|
|
||||||
|
Shape shape = GUIPaintUtils.paintShape(g2d, wdith, heigth, REC); |
||||||
|
g2d.setClip(shape); |
||||||
|
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
||||||
|
super.paintComponent(g2d); |
||||||
|
} |
||||||
|
}; |
||||||
|
popupMenu.setInvoker(this); |
||||||
|
popupListener = createWinListener(popupMenu); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
*画界面 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void updateUI() { |
||||||
|
setUI(new UIMenuUI()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 判断popupmeu是否隐藏 |
||||||
|
* @return 如果隐藏 返回true |
||||||
|
*/ |
||||||
|
public boolean isPopupMenuVisible() { |
||||||
|
ensurePopupMenuCreated(); |
||||||
|
return popupMenu.isVisible(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 设置popupmenu位置 |
||||||
|
* @param x |
||||||
|
* @param y |
||||||
|
*/ |
||||||
|
public void setMenuLocation(int x, int y) { |
||||||
|
super.setMenuLocation(x, y); |
||||||
|
if (popupMenu != null) { |
||||||
|
popupMenu.setLocation(x, y); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 向popupmenu添加 JMenuItem |
||||||
|
* @param menuItem 菜单项 |
||||||
|
* @return 菜单项 |
||||||
|
*/ |
||||||
|
public JMenuItem add(JMenuItem menuItem) { |
||||||
|
ensurePopupMenuCreated(); |
||||||
|
return popupMenu.add(menuItem); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加组件 |
||||||
|
* @param c 组件 |
||||||
|
* @return 组件 |
||||||
|
*/ |
||||||
|
public Component add(Component c) { |
||||||
|
ensurePopupMenuCreated(); |
||||||
|
popupMenu.add(c); |
||||||
|
return c; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 向指定位置添加组件 |
||||||
|
* @param c 组件 |
||||||
|
* @param index 位置 |
||||||
|
* @return 组件 |
||||||
|
*/ |
||||||
|
public Component add(Component c, int index) { |
||||||
|
ensurePopupMenuCreated(); |
||||||
|
popupMenu.add(c, index); |
||||||
|
return c; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 添加分隔符 |
||||||
|
*/ |
||||||
|
public void addSeparator() { |
||||||
|
ensurePopupMenuCreated(); |
||||||
|
popupMenu.addSeparator(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加menuitem到指定位置 |
||||||
|
* @param s 字符 |
||||||
|
* @param pos 位置 |
||||||
|
*/ |
||||||
|
public void insert(String s, int pos) { |
||||||
|
if (pos < 0) { |
||||||
|
throw new IllegalArgumentException("index less than zero."); |
||||||
|
} |
||||||
|
|
||||||
|
ensurePopupMenuCreated(); |
||||||
|
popupMenu.insert(new JMenuItem(s), pos); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加么会特么到指定位置 |
||||||
|
* @param mi 菜单项 |
||||||
|
* @param pos 位置 |
||||||
|
* @return 菜单项 |
||||||
|
*/ |
||||||
|
public JMenuItem insert(JMenuItem mi, int pos) { |
||||||
|
if (pos < 0) { |
||||||
|
throw new IllegalArgumentException("index less than zero."); |
||||||
|
} |
||||||
|
ensurePopupMenuCreated(); |
||||||
|
popupMenu.insert(mi, pos); |
||||||
|
return mi; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加到指定位置 |
||||||
|
* @param a 事件 |
||||||
|
* @param pos 位置 |
||||||
|
* @return 菜单项 |
||||||
|
*/ |
||||||
|
public JMenuItem insert(Action a, int pos) { |
||||||
|
if (pos < 0) { |
||||||
|
throw new IllegalArgumentException("index less than zero."); |
||||||
|
} |
||||||
|
|
||||||
|
ensurePopupMenuCreated(); |
||||||
|
JMenuItem mi = new JMenuItem(a); |
||||||
|
mi.setHorizontalTextPosition(JButton.TRAILING); |
||||||
|
mi.setVerticalTextPosition(JButton.CENTER); |
||||||
|
popupMenu.insert(mi, pos); |
||||||
|
return mi; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加分隔符到指定位置 |
||||||
|
* @param index 指定位置 |
||||||
|
*/ |
||||||
|
public void insertSeparator(int index) { |
||||||
|
if (index < 0) { |
||||||
|
throw new IllegalArgumentException("index less than zero."); |
||||||
|
} |
||||||
|
|
||||||
|
ensurePopupMenuCreated(); |
||||||
|
popupMenu.insert(new JPopupMenu.Separator(), index); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 移除 |
||||||
|
* @param item 菜单项 |
||||||
|
*/ |
||||||
|
public void remove(JMenuItem item) { |
||||||
|
if (popupMenu != null) { |
||||||
|
popupMenu.remove(item); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 移除指定位置菜单项 |
||||||
|
* @param pos 指定位置 |
||||||
|
*/ |
||||||
|
public void remove(int pos) { |
||||||
|
if (pos < 0) { |
||||||
|
throw new IllegalArgumentException("index less than zero."); |
||||||
|
} |
||||||
|
if (pos > getItemCount()) { |
||||||
|
throw new IllegalArgumentException("index greater than the number of items."); |
||||||
|
} |
||||||
|
if (popupMenu != null) { |
||||||
|
popupMenu.remove(pos); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 移除组件 |
||||||
|
* @param c 组件 |
||||||
|
*/ |
||||||
|
public void remove(Component c) { |
||||||
|
if (popupMenu != null) { |
||||||
|
popupMenu.remove(c); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 移除所有 |
||||||
|
*/ |
||||||
|
public void removeAll() { |
||||||
|
if (popupMenu != null) { |
||||||
|
popupMenu.removeAll(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 组件总数 |
||||||
|
* @return 组件总数 |
||||||
|
*/ |
||||||
|
public int getMenuComponentCount() { |
||||||
|
return (popupMenu == null) ? 0 : popupMenu.getComponentCount(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 指定位置组件 |
||||||
|
* @param n 指定位置 |
||||||
|
* @return 组件 |
||||||
|
*/ |
||||||
|
public Component getMenuComponent(int n) { |
||||||
|
return (popupMenu == null) ? null : popupMenu.getComponent(n); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 所有组件 |
||||||
|
* @return 所有组件 |
||||||
|
*/ |
||||||
|
public Component[] getMenuComponents() { |
||||||
|
return (popupMenu == null) ? new Component[0] : popupMenu.getComponents(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
After Width: | Height: | Size: 500 B |
Before Width: | Height: | Size: 511 B After Width: | Height: | Size: 167 B |
@ -0,0 +1,42 @@ |
|||||||
|
package com.fr.design.mainframe.widget.accessibles; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.general.cardtag.TemplateStyle; |
||||||
|
import com.fr.design.mainframe.widget.wrappers.TemplateStyleWrapper; |
||||||
|
|
||||||
|
import javax.swing.SwingUtilities; |
||||||
|
import java.awt.Dimension; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2017/11/23. |
||||||
|
*/ |
||||||
|
public class AccessibleTemplateStyleEditor extends UneditableAccessibleEditor { |
||||||
|
|
||||||
|
private static final Dimension DEFAULT_DIMENSION = new Dimension(600, 400); |
||||||
|
|
||||||
|
private TemplateStylePane stylePane; |
||||||
|
|
||||||
|
public AccessibleTemplateStyleEditor() { |
||||||
|
super(new TemplateStyleWrapper()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void showEditorPane() { |
||||||
|
if (stylePane == null) { |
||||||
|
stylePane = new TemplateStylePane(); |
||||||
|
stylePane.setPreferredSize(DEFAULT_DIMENSION); |
||||||
|
} |
||||||
|
BasicDialog dlg = stylePane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||||
|
dlg.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void doOk() { |
||||||
|
setValue(stylePane.update()); |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
stylePane.populate((TemplateStyle) getValue()); |
||||||
|
dlg.setVisible(true); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,99 @@ |
|||||||
|
package com.fr.design.mainframe.widget.accessibles; |
||||||
|
|
||||||
|
import com.fr.general.cardtag.BannerTemplateStyle; |
||||||
|
import com.fr.general.cardtag.BookMarkTemplateStyle; |
||||||
|
import com.fr.general.cardtag.CardTemplateStyle; |
||||||
|
import com.fr.general.cardtag.DefaultTemplateStyle; |
||||||
|
import com.fr.general.cardtag.MenuTemplateStyle; |
||||||
|
import com.fr.general.cardtag.PentagonTemplateStyle; |
||||||
|
import com.fr.general.cardtag.TrapezoidTemplateStyle; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.general.cardtag.TemplateStyle; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.DefaultListCellRenderer; |
||||||
|
import javax.swing.DefaultListModel; |
||||||
|
import javax.swing.JList; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.ListCellRenderer; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2017/11/23. |
||||||
|
*/ |
||||||
|
public class TemplateStylePane extends BasicPane { |
||||||
|
private DefaultListModel listModel; |
||||||
|
private JList styleList; |
||||||
|
private TemplateStylePreviewPane previewPane = new TemplateStylePreviewPane(new DefaultTemplateStyle()); |
||||||
|
|
||||||
|
public TemplateStylePane(){ |
||||||
|
init(); |
||||||
|
} |
||||||
|
|
||||||
|
public void init(){ |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
listModel = new DefaultListModel(); |
||||||
|
listModel.addElement(new DefaultTemplateStyle()); |
||||||
|
listModel.addElement(new CardTemplateStyle()); |
||||||
|
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); |
||||||
|
|
||||||
|
JPanel westPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
westPane.add(styleList, BorderLayout.CENTER); |
||||||
|
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||||
|
westPane.setPreferredSize(new Dimension(100, 500)); |
||||||
|
centerPane.setPreferredSize(new Dimension(300, 500)); |
||||||
|
centerPane.setBorder(GUICoreUtils.createTitledBorder(Inter.getLocText("Preview"), null)); |
||||||
|
centerPane.add(previewPane); |
||||||
|
styleList.addMouseListener(new MouseAdapter() { |
||||||
|
public void mouseClicked(MouseEvent e) { |
||||||
|
previewPane.repaint((TemplateStyle) styleList.getSelectedValue()); |
||||||
|
} |
||||||
|
}); |
||||||
|
this.add(westPane, BorderLayout.WEST); |
||||||
|
this.add(centerPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
public static ListCellRenderer render = new DefaultListCellRenderer() { |
||||||
|
@Override |
||||||
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||||
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||||
|
|
||||||
|
if (value instanceof TemplateStyle) { |
||||||
|
TemplateStyle l = (TemplateStyle) value; |
||||||
|
this.setText(l.toString()); |
||||||
|
} |
||||||
|
return this; |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Inter.getLocText("FR-Designer_Tab_Style_Template"); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(TemplateStyle templateStyle) { |
||||||
|
previewPane.repaint(templateStyle); |
||||||
|
for(int i = 0; i< listModel.getSize(); i++){ |
||||||
|
if((listModel.getElementAt(i).toString()).equals(templateStyle.toString())){ |
||||||
|
styleList.setSelectedIndex(i); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
styleList.setSelectedIndex(0); |
||||||
|
} |
||||||
|
|
||||||
|
public TemplateStyle update() { |
||||||
|
return (TemplateStyle) styleList.getSelectedValue(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
package com.fr.design.mainframe.widget.accessibles; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.general.cardtag.TemplateStyle; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.Graphics; |
||||||
|
import java.awt.Graphics2D; |
||||||
|
import java.awt.Image; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2017/12/11. |
||||||
|
*/ |
||||||
|
public class TemplateStylePreviewPane extends JPanel { |
||||||
|
|
||||||
|
private static final int WIDTH = 540; |
||||||
|
private static final int HEIGHT = 500; |
||||||
|
|
||||||
|
private TemplateStyle templateStyle; |
||||||
|
|
||||||
|
public TemplateStylePreviewPane(TemplateStyle templateStyle){ |
||||||
|
this.templateStyle = templateStyle; |
||||||
|
} |
||||||
|
|
||||||
|
public void repaint (TemplateStyle templateStyle){ |
||||||
|
this.templateStyle = templateStyle; |
||||||
|
super.repaint(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void paint(Graphics g) { |
||||||
|
super.paint(g); |
||||||
|
Graphics2D g2d = (Graphics2D) g.create(); |
||||||
|
Image image = BaseUtils.readImage(templateStyle.getPreview()); |
||||||
|
g2d.drawImage(image, 0, 0, WIDTH, HEIGHT, null); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
package com.fr.design.mainframe.widget.wrappers; |
||||||
|
|
||||||
|
import com.fr.design.Exception.ValidationException; |
||||||
|
import com.fr.design.designer.properties.Decoder; |
||||||
|
import com.fr.design.designer.properties.Encoder; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2017/11/23. |
||||||
|
*/ |
||||||
|
public class TemplateStyleWrapper implements Encoder, Decoder { |
||||||
|
@Override |
||||||
|
public String encode(Object v) { |
||||||
|
if (v == null) { |
||||||
|
return StringUtils.EMPTY; |
||||||
|
} |
||||||
|
return v.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object decode(String txt) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void validate(String txt) throws ValidationException { |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,76 @@ |
|||||||
|
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.gui.ispinner.UISpinner; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.design.mainframe.WidgetPropertyPane; |
||||||
|
import com.fr.design.widget.WidgetBoundsPaneFactory; |
||||||
|
import com.fr.form.ui.container.WTabDisplayPosition; |
||||||
|
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import java.awt.Rectangle; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2017/12/4. |
||||||
|
*/ |
||||||
|
public class WidgetCardTagBoundPane extends WidgetBoundPane { |
||||||
|
private UISpinner cardTagWidth ; |
||||||
|
|
||||||
|
public WidgetCardTagBoundPane(XCreator source) { |
||||||
|
super(source); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void initBoundPane() { |
||||||
|
cardTagWidth = new UIBoundSpinner(0, Integer.MAX_VALUE, 1); |
||||||
|
cardTagWidth.setGlobalName(Inter.getLocText("FR-Designer_Coords_And_Size")); |
||||||
|
this.add(WidgetBoundsPaneFactory.createCardTagBoundPane(cardTagWidth)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void update() { |
||||||
|
if (parent == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
||||||
|
Rectangle parentBounds = new Rectangle(parent.getBounds()); |
||||||
|
|
||||||
|
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(); |
||||||
|
}else{ |
||||||
|
parentBounds.width = (int)cardTagWidth.getValue(); |
||||||
|
} |
||||||
|
|
||||||
|
parent.setBounds(parentBounds); |
||||||
|
LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(formDesigner, parent); |
||||||
|
if (layoutAdapter != null) { |
||||||
|
parent.setBackupBound(parent.getBounds()); |
||||||
|
layoutAdapter.fix(parent); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "absoluteBound"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populate() { |
||||||
|
WCardTagLayout tagLayout = (WCardTagLayout)creator.toData(); |
||||||
|
Rectangle bounds = new Rectangle(creator.getBounds()); |
||||||
|
WTabDisplayPosition displayPosition = tagLayout.getDisplayPosition(); |
||||||
|
if( ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){ |
||||||
|
cardTagWidth.setValue(bounds.height); |
||||||
|
}else{ |
||||||
|
cardTagWidth.setValue(bounds.width); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,39 +1,92 @@ |
|||||||
package com.fr.design.widget.ui.designer.layout; |
package com.fr.design.widget.ui.designer.layout; |
||||||
|
|
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
import com.fr.design.designer.creator.XCreator; |
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.foldablepane.UIExpandablePane; |
||||||
|
import com.fr.design.gui.icheckbox.UICheckBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.ispinner.UISpinner; |
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.mainframe.widget.accessibles.AccessibleCardTagWLayoutBorderStyleEditor; |
||||||
import com.fr.design.widget.ui.designer.AbstractDataModify; |
import com.fr.design.widget.ui.designer.AbstractDataModify; |
||||||
|
import com.fr.form.ui.LayoutBorderStyle; |
||||||
|
import com.fr.form.ui.container.WCardLayout; |
||||||
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; |
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; |
||||||
import java.awt.*; |
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
/** |
/** |
||||||
* Created by ibm on 2017/8/2. |
* Created by ibm on 2017/8/2. |
||||||
*/ |
*/ |
||||||
public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBorderLayout> { |
public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBorderLayout> { |
||||||
|
private AccessibleCardTagWLayoutBorderStyleEditor accessibleCardTagWLayoutBorderStyleEditor; |
||||||
|
private UICheckBox setCarousel; |
||||||
|
private UISpinner carouselInterval; |
||||||
|
private JPanel IntervalPane; |
||||||
|
|
||||||
public WCardMainLayoutDefinePane(XCreator xCreator) { |
public WCardMainLayoutDefinePane(XCreator xCreator) { |
||||||
super(xCreator); |
super(xCreator); |
||||||
this.setPreferredSize(new Dimension(0,0)); |
initComponent(); |
||||||
} |
} |
||||||
|
|
||||||
public void initComponent() { |
public void initComponent() { |
||||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
carouselInterval = new UISpinner(0, 20, 1, 0); |
||||||
|
accessibleCardTagWLayoutBorderStyleEditor = new AccessibleCardTagWLayoutBorderStyleEditor(); |
||||||
|
JPanel accessibleCardlayout = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
JPanel stylePane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ |
||||||
|
new Component[]{new UILabel(Inter.getLocText("FR-Designer-Widget_Style")), accessibleCardTagWLayoutBorderStyleEditor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); |
||||||
|
stylePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); |
||||||
|
accessibleCardlayout.add(stylePane, BorderLayout.CENTER); |
||||||
|
UIExpandablePane advanceExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 20, accessibleCardlayout); |
||||||
|
final JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
jPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
||||||
|
setCarousel = new UICheckBox(Inter.getLocText("FR-Designer_setCarousel")); |
||||||
|
IntervalPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{ |
||||||
|
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)); |
||||||
|
jPanel.add(setCarousel, BorderLayout.NORTH); |
||||||
|
jPanel.add(IntervalPane, BorderLayout.CENTER); |
||||||
|
setCarousel.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
IntervalPane.setVisible(setCarousel.isSelected()); |
||||||
|
} |
||||||
|
}); |
||||||
|
UIExpandablePane setCarouselPane = new UIExpandablePane(Inter.getLocText("FR-Designer_Tab_carousel"), 280, 20, jPanel); |
||||||
|
this.add(advanceExpandablePane, BorderLayout.NORTH); |
||||||
|
this.add(setCarouselPane, BorderLayout.CENTER); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public String title4PopupWindow() { |
public String title4PopupWindow() { |
||||||
return "cardMainLayout"; |
return "tabFitLayout"; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void populateBean(WCardMainBorderLayout ob) { |
public void populateBean(WCardMainBorderLayout ob) { |
||||||
|
WCardLayout cardLayout = ob.getCardPart(); |
||||||
|
accessibleCardTagWLayoutBorderStyleEditor.setValue(ob.getBorderStyle()); |
||||||
|
setCarousel.setSelected(cardLayout.isCarousel()); |
||||||
|
IntervalPane.setVisible(ob.isCarousel()); |
||||||
|
carouselInterval.setValue(cardLayout.getCarouselInterval()); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
@Override |
@Override |
||||||
public WCardMainBorderLayout updateBean() { |
public WCardMainBorderLayout updateBean() { |
||||||
WCardMainBorderLayout layout = (WCardMainBorderLayout) creator.toData(); |
WCardMainBorderLayout layout = (WCardMainBorderLayout) creator.toData(); |
||||||
|
layout.setBorderStyle((LayoutBorderStyle) accessibleCardTagWLayoutBorderStyleEditor.getValue()); |
||||||
|
WCardLayout wCardLayout = layout.getCardPart(); |
||||||
|
wCardLayout.setCarousel(setCarousel.isSelected()); |
||||||
|
wCardLayout.setCarouselInterval((int)carouselInterval.getValue()); |
||||||
return layout; |
return layout; |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -0,0 +1,114 @@ |
|||||||
|
package com.fr.design.widget.ui.designer.layout; |
||||||
|
|
||||||
|
import com.fr.general.cardtag.TemplateStyle; |
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
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.foldablepane.UIExpandablePane; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.style.FRFontPane; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.mainframe.widget.accessibles.AccessibleImgBackgroundEditor; |
||||||
|
import com.fr.design.mainframe.widget.accessibles.AccessibleTemplateStyleEditor; |
||||||
|
import com.fr.design.widget.ui.designer.AbstractDataModify; |
||||||
|
import com.fr.form.ui.LayoutBorderStyle; |
||||||
|
import com.fr.form.ui.container.WTabDisplayPosition; |
||||||
|
import com.fr.form.ui.container.WTabTextDirection; |
||||||
|
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||||
|
import com.fr.general.Background; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.BorderFactory; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.SwingConstants; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2017/11/16. |
||||||
|
*/ |
||||||
|
public class WCardTagLayoutDefinePane extends AbstractDataModify<WCardTagLayout> { |
||||||
|
private AccessibleImgBackgroundEditor backgroundEditor; |
||||||
|
private FRFontPane frFontPane; |
||||||
|
private UIButtonGroup displayPositionGroup; |
||||||
|
private UIButtonGroup textDirectionGroup; |
||||||
|
private AccessibleTemplateStyleEditor templateStyleEditor; |
||||||
|
|
||||||
|
public WCardTagLayoutDefinePane(XCreator xCreator) { |
||||||
|
super(xCreator); |
||||||
|
initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
public void initComponent() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
|
||||||
|
backgroundEditor = new AccessibleImgBackgroundEditor(); |
||||||
|
templateStyleEditor = new AccessibleTemplateStyleEditor(); |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double[] rowSize = {p, p, p, p, p}; |
||||||
|
double[] columnSize = {p, f}; |
||||||
|
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; |
||||||
|
|
||||||
|
UILabel fontLabel = new UILabel(Inter.getLocText("FR-Designer_Font")); |
||||||
|
fontLabel.setVerticalAlignment(SwingConstants.TOP); |
||||||
|
frFontPane = new FRFontPane(); |
||||||
|
displayPositionGroup = new UIButtonGroup(WTabDisplayPosition.getStringArray()); |
||||||
|
textDirectionGroup = new UIButtonGroup(WTabTextDirection.getStringArray()); |
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Tab_Style_Template")), templateStyleEditor}, |
||||||
|
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Tab_Display_Position")), displayPositionGroup}, |
||||||
|
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background")), backgroundEditor}, |
||||||
|
new Component[]{fontLabel, frFontPane}, |
||||||
|
new Component[]{new UILabel(Inter.getLocText("FR-Designer_StyleAlignment_Text_Rotation")), textDirectionGroup} |
||||||
|
}; |
||||||
|
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); |
||||||
|
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); |
||||||
|
jPanel.add(panel, BorderLayout.CENTER); |
||||||
|
UIExpandablePane advanceExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 20, jPanel); |
||||||
|
this.add(advanceExpandablePane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String title4PopupWindow() { |
||||||
|
return "tabFitLayout"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(WCardTagLayout ob) { |
||||||
|
//标题背景和字体属性设置在WCardLayout上做兼容
|
||||||
|
XLayoutContainer topLayout = creator.getTopLayout(); |
||||||
|
LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout)topLayout).getCardPart().toData().getBorderStyle(); |
||||||
|
|
||||||
|
displayPositionGroup.setSelectedIndex(ob.getDisplayPosition().getType()); |
||||||
|
textDirectionGroup.setSelectedIndex(ob.getTextDirection().getType()); |
||||||
|
backgroundEditor.setValue(layoutBorderStyle.getTitle().getBackground()); |
||||||
|
templateStyleEditor.setValue(ob.getTemplateStyle()); |
||||||
|
FRFont frFont = layoutBorderStyle.getTitle().getFrFont(); |
||||||
|
if (frFont != null) { |
||||||
|
frFontPane.populateBean(frFont); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public WCardTagLayout updateBean() { |
||||||
|
//标题背景和字体属性设置在WCardLayout上做兼容
|
||||||
|
XLayoutContainer topLayout = creator.getTopLayout(); |
||||||
|
LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout)topLayout).getCardPart().toData().getBorderStyle(); |
||||||
|
FRFont frFont = layoutBorderStyle.getTitle().getFrFont() == null ? FRFont.getInstance() : layoutBorderStyle.getTitle().getFrFont(); |
||||||
|
layoutBorderStyle.getTitle().setBackground((Background) backgroundEditor.getValue()); |
||||||
|
layoutBorderStyle.getTitle().setFrFont(frFontPane.update(frFont)); |
||||||
|
WCardTagLayout layout = (WCardTagLayout) creator.toData(); |
||||||
|
layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex())); |
||||||
|
layout.setTextDirection(WTabTextDirection.parse(textDirectionGroup.getSelectedIndex())); |
||||||
|
layout.setTemplateStyle((TemplateStyle) templateStyleEditor.getValue()); |
||||||
|
|
||||||
|
return layout; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue