111 changed files with 3220 additions and 1031 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 |
After Width: | Height: | Size: 173 B |
Before Width: | Height: | Size: 511 B After Width: | Height: | Size: 167 B |
After Width: | Height: | Size: 274 B |
After Width: | Height: | Size: 278 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,59 @@ |
|||||||
|
package com.fr.design.designer.beans.actions; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.designer.beans.events.DesignerEvent; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.design.mainframe.FormSelection; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.InputEvent; |
||||||
|
import java.awt.event.KeyEvent; |
||||||
|
|
||||||
|
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; |
||||||
|
|
||||||
|
/** |
||||||
|
* 下移一层(控件树内) |
||||||
|
* Created by plough on 2017/12/4. |
||||||
|
*/ |
||||||
|
|
||||||
|
public class MoveDownAction extends FormEditAction { |
||||||
|
|
||||||
|
public MoveDownAction(FormDesigner t) { |
||||||
|
super(t); |
||||||
|
this.setName(Inter.getLocText("FR-Designer_Move_Down")); |
||||||
|
this.setMnemonic('B'); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/down.png")); |
||||||
|
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, DEFAULT_MODIFIER)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean executeActionReturnUndoRecordNeeded() { |
||||||
|
FormDesigner designer = getEditingComponent(); |
||||||
|
if (designer == null) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
FormSelection selection = designer.getSelectionModel().getSelection(); |
||||||
|
XCreator creator = selection.getSelectedCreator(); |
||||||
|
Container container = creator.getParent(); |
||||||
|
int targetIndex = container.getComponentZOrder(creator) + 1; |
||||||
|
if (targetIndex >= container.getComponentCount()) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
container.setComponentZOrder(creator, targetIndex); |
||||||
|
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_DELETED); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void update() { |
||||||
|
FormDesigner designer = getEditingComponent(); |
||||||
|
if (designer == null) { |
||||||
|
this.setEnabled(false); |
||||||
|
return; |
||||||
|
} |
||||||
|
this.setEnabled(designer.isCurrentComponentMovableDown()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
package com.fr.design.designer.beans.actions; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.designer.beans.events.DesignerEvent; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.design.mainframe.FormSelection; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.InputEvent; |
||||||
|
import java.awt.event.KeyEvent; |
||||||
|
|
||||||
|
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; |
||||||
|
|
||||||
|
/** |
||||||
|
* 置于底层(控件树内) |
||||||
|
* Created by plough on 2017/12/4. |
||||||
|
*/ |
||||||
|
|
||||||
|
public class MoveToBottomAction extends FormEditAction { |
||||||
|
|
||||||
|
public MoveToBottomAction(FormDesigner t) { |
||||||
|
super(t); |
||||||
|
this.setName(Inter.getLocText("FR-Designer_Move_To_Bottom")); |
||||||
|
this.setMnemonic('K'); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/to_bottom.png")); |
||||||
|
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, DEFAULT_MODIFIER + InputEvent.ALT_MASK)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean executeActionReturnUndoRecordNeeded() { |
||||||
|
FormDesigner designer = getEditingComponent(); |
||||||
|
if (designer == null) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
FormSelection selection = designer.getSelectionModel().getSelection(); |
||||||
|
XCreator creator = selection.getSelectedCreator(); |
||||||
|
Container container = creator.getParent(); |
||||||
|
int targetIndex = container.getComponentCount() - 1; |
||||||
|
if (container.getComponentZOrder(creator) >= targetIndex) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
container.setComponentZOrder(creator, targetIndex); |
||||||
|
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_DELETED); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void update() { |
||||||
|
FormDesigner designer = getEditingComponent(); |
||||||
|
if (designer == null) { |
||||||
|
this.setEnabled(false); |
||||||
|
return; |
||||||
|
} |
||||||
|
this.setEnabled(designer.isCurrentComponentMovableDown()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,59 @@ |
|||||||
|
package com.fr.design.designer.beans.actions; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.designer.beans.events.DesignerEvent; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.design.mainframe.FormSelection; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.InputEvent; |
||||||
|
import java.awt.event.KeyEvent; |
||||||
|
|
||||||
|
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; |
||||||
|
|
||||||
|
/** |
||||||
|
* 置于顶层(控件树内) |
||||||
|
* Created by plough on 2017/12/4. |
||||||
|
*/ |
||||||
|
|
||||||
|
public class MoveToTopAction extends FormEditAction { |
||||||
|
|
||||||
|
public MoveToTopAction(FormDesigner t) { |
||||||
|
super(t); |
||||||
|
this.setName(Inter.getLocText("FR-Designer_Move_To_Top")); |
||||||
|
this.setMnemonic('T'); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/to_top.png")); |
||||||
|
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, DEFAULT_MODIFIER + InputEvent.ALT_MASK)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean executeActionReturnUndoRecordNeeded() { |
||||||
|
FormDesigner designer = getEditingComponent(); |
||||||
|
if (designer == null) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
FormSelection selection = designer.getSelectionModel().getSelection(); |
||||||
|
XCreator creator = selection.getSelectedCreator(); |
||||||
|
Container container = creator.getParent(); |
||||||
|
if (container.getComponentZOrder(creator) == 0) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
container.setComponentZOrder(creator, 0); |
||||||
|
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_DELETED); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void update() { |
||||||
|
FormDesigner designer = getEditingComponent(); |
||||||
|
if (designer == null) { |
||||||
|
this.setEnabled(false); |
||||||
|
return; |
||||||
|
} |
||||||
|
this.setEnabled(designer.isCurrentComponentMovableUp()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,59 @@ |
|||||||
|
package com.fr.design.designer.beans.actions; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.designer.beans.events.DesignerEvent; |
||||||
|
import com.fr.design.designer.creator.XCreator; |
||||||
|
import com.fr.design.mainframe.FormDesigner; |
||||||
|
import com.fr.design.mainframe.FormSelection; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.KeyEvent; |
||||||
|
|
||||||
|
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; |
||||||
|
|
||||||
|
/** |
||||||
|
* 同级上移一层(控件树内) |
||||||
|
* Created by plough on 2017/12/4. |
||||||
|
*/ |
||||||
|
|
||||||
|
public class MoveUpAction extends FormEditAction { |
||||||
|
|
||||||
|
public MoveUpAction(FormDesigner t) { |
||||||
|
super(t); |
||||||
|
this.setName(Inter.getLocText("FR-Designer_Move_Up")); |
||||||
|
this.setMnemonic('F'); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/up.png")); |
||||||
|
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_CLOSE_BRACKET, DEFAULT_MODIFIER)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean executeActionReturnUndoRecordNeeded() { |
||||||
|
FormDesigner designer = getEditingComponent(); |
||||||
|
if (designer == null) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
FormSelection selection = designer.getSelectionModel().getSelection(); |
||||||
|
XCreator creator = selection.getSelectedCreator(); |
||||||
|
Container container = creator.getParent(); |
||||||
|
int targetIndex = container.getComponentZOrder(creator) - 1; |
||||||
|
if (targetIndex < 0) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
container.setComponentZOrder(creator, targetIndex); |
||||||
|
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_DELETED); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void update() { |
||||||
|
FormDesigner designer = getEditingComponent(); |
||||||
|
if (designer == null) { |
||||||
|
this.setEnabled(false); |
||||||
|
return; |
||||||
|
} |
||||||
|
this.setEnabled(designer.isCurrentComponentMovableUp()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue