diff --git a/designer/src/com/fr/grid/selection/FloatSelection.java b/designer/src/com/fr/grid/selection/FloatSelection.java index 60fe54b7cb..0d441a1f7a 100644 --- a/designer/src/com/fr/grid/selection/FloatSelection.java +++ b/designer/src/com/fr/grid/selection/FloatSelection.java @@ -5,17 +5,16 @@ import com.fr.base.FRContext; import com.fr.design.actions.cell.CleanAuthorityAction; import com.fr.design.actions.cell.FloatStyleAction; import com.fr.design.actions.core.ActionFactory; -import com.fr.design.actions.edit.CopyAction; -import com.fr.design.actions.edit.CutAction; -import com.fr.design.actions.edit.DeleteAction; -import com.fr.design.actions.edit.EditFloatElementNameAction; -import com.fr.design.actions.edit.HyperlinkAction; -import com.fr.design.actions.edit.PasteAction; -import com.fr.design.actions.utils.DeprecatedActionManager; +import com.fr.design.actions.edit.*; +import com.fr.design.actions.edit.order.BringFloatElementForwardAction; +import com.fr.design.actions.edit.order.BringFloatElementToFrontAction; +import com.fr.design.actions.edit.order.SendFloatElementBackwardAction; +import com.fr.design.actions.edit.order.SendFloatElementToBackAction; import com.fr.design.cell.clipboard.CellElementsClip; import com.fr.design.cell.clipboard.ElementsTransferable; import com.fr.design.cell.clipboard.FloatElementsClip; import com.fr.design.designer.TargetComponent; +import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane.Clear; @@ -29,12 +28,10 @@ import com.fr.stable.ColumnRow; import com.fr.stable.unit.FU; import com.fr.stable.unit.OLDPIX; -import javax.swing.JPopupMenu; -import java.awt.Toolkit; - +import javax.swing.*; +import java.awt.*; /** * the float selection - * * @editor zhou * 2012-3-22下午2:09:20 */ @@ -120,24 +117,28 @@ public class FloatSelection extends Selection { @Override public JPopupMenu createPopupMenu(ElementCasePane ePane) { - JPopupMenu popup = new JPopupMenu(); + UIPopupMenu popup = new UIPopupMenu(); if (BaseUtils.isAuthorityEditing()) { popup.add(new CleanAuthorityAction(ePane).createMenuItem()); return popup; } - popup.add(DeprecatedActionManager.getCellMenu(ePane).createJMenu()); popup.add(new FloatStyleAction(ePane).createMenuItem()); popup.add(new HyperlinkAction().createMenuItem()); - // cut, copy and paste popup.addSeparator(); + popup.add(new CutAction(ePane).createMenuItem()); popup.add(new CopyAction(ePane).createMenuItem()); popup.add(new PasteAction(ePane).createMenuItem()); popup.add(new DeleteAction(ePane).createMenuItem()); + popup.addSeparator(); + popup.add(new BringFloatElementToFrontAction(ePane).createMenuItem()); + popup.add(new SendFloatElementToBackAction(ePane).createMenuItem()); + popup.add(new BringFloatElementForwardAction(ePane).createMenuItem()); + popup.add(new SendFloatElementBackwardAction(ePane).createMenuItem()); popup.addSeparator(); - popup.add(DeprecatedActionManager.getOrderMenu(ePane)); + popup.add(new EditFloatElementNameAction(ePane).createMenuItem()); return popup; @@ -148,8 +149,8 @@ public class FloatSelection extends Selection { TemplateElementCase ec = ePane.getEditingElementCase(); FloatElement fe = ec.getFloatElement(selectedFloatName); if (fe != null) { - ePane.setSelection(new CellSelection(0, 0, 1, 1)); ec.removeFloatElement(fe); + ePane.setSelection(new CellSelection(0, 0, 1, 1)); return true; } @@ -215,7 +216,6 @@ public class FloatSelection extends Selection { public boolean isSelectedOneCell(ElementCasePane ePane) { return false; } - //TODO:august 这儿不比较FloatElement会不会有问题啊 @Override public boolean equals(Object obj) { @@ -239,8 +239,8 @@ public class FloatSelection extends Selection { CellElementPropertyPane.getInstance().removeAll(); } - public void populateWidgetPropertyPane(ElementCasePane ePane) { - + public void populateWidgetPropertyPane(ElementCasePane ePane){ + return; } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java b/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java index 796071ce23..eb93f09fd3 100644 --- a/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java @@ -3,7 +3,7 @@ package com.fr.design.file; import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; -import com.fr.design.actions.core.ActionFactory; +import com.fr.base.vcs.DesignerMode; import com.fr.design.constants.UIConstants; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIScrollPopUpMenu; @@ -17,41 +17,15 @@ import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.Constants; +import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.project.ProjectConstants; -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.ButtonModel; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JSeparator; +import javax.swing.*; import javax.swing.plaf.basic.BasicMenuItemUI; -import java.awt.AWTEvent; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.GradientPaint; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.RenderingHints; -import java.awt.Toolkit; -import java.awt.event.AWTEventListener; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.awt.geom.Arc2D; -import java.awt.geom.GeneralPath; -import java.awt.geom.Line2D; -import java.awt.geom.Path2D; -import java.awt.geom.RoundRectangle2D; +import java.awt.*; +import java.awt.event.*; +import java.awt.geom.*; import java.io.File; import java.util.logging.Level; @@ -247,12 +221,10 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M templates[i].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectedIndex = index; - DesignerContext.getDesignerFrame().addAndActivateJTemplate(tem); + tem.activeNewJTemplate(); } }); } - - return templates; } @@ -661,6 +633,11 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M * @param e 鼠标事件 */ public void mousePressed(MouseEvent e) { + //如果在版本管理情况下,不允许切换tab + if (DesignerMode.isVcsMode()) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Vcs_tab_click"), Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); + return; + } int evtX = e.getX(); int evtY = e.getY(); @@ -700,7 +677,8 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M this.repaint(); return; } - DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(getTemplateIndex(evtX))); + JTemplate evtXTemplate = openedTemplate.get(getTemplateIndex(evtX)); + evtXTemplate.activeNewJTemplate(); } isShowList = false; } @@ -729,8 +707,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M if (filename.startsWith(ProjectConstants.REPORTLETS_NAME)) { filename = ((FileNodeFILE) openedTemplate.get(selectedIndex).getEditingFILE()).getEnvPath() + File.separator + filename; } - - filename = filename.replaceAll("/", "\\\\"); + filename = OperatingSystem.isWindows() ? filename.replaceAll("/", "\\\\") : filename.replaceAll("\\\\", "/"); if (!specifiedTemplate.isALLSaved()) { specifiedTemplate.stopEditing(); @@ -739,10 +716,21 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { specifiedTemplate.saveTemplate(); FRLogger.getLogger().log(Level.INFO, Inter.getLocText(new String[]{"Template", "already-saved"}, new String[]{specifiedTemplate.getEditingFILE().getName(), "."})); + HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); + activeTemplate(filename); + } else if (returnVal == JOptionPane.NO_OPTION) { + //不保存 + HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); + activeTemplate(filename); } + //若是点击取消关闭,则什么都不做 + } else { + //若是已经保存过了,则关闭即可 + HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); + activeTemplate(filename); } - HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); - activeTemplate(filename); + + } /** @@ -796,7 +784,8 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M //如果关闭的模板不是当前选中的模板,则激活的模板不变 selectedIndex = HistoryTemplateListPane.getInstance().contains(fileName); } - DesignerContext.getDesignerFrame().activateJTemplate(openedTemplate.get(selectedIndex)); + //如果是已后台关闭的模板,则重新打开文件 + openedTemplate.get(selectedIndex).activeOldJTemplate(); } } @@ -968,6 +957,4 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M } } } - - } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/mainframe/JSliderPane.java b/designer_base/src/com/fr/design/mainframe/JSliderPane.java index 2562755e57..ff30054b45 100644 --- a/designer_base/src/com/fr/design/mainframe/JSliderPane.java +++ b/designer_base/src/com/fr/design/mainframe/JSliderPane.java @@ -6,6 +6,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ibutton.UISliderButton; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.islider.UISlider; import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.gui.ispinner.UISpinnerUI; @@ -15,33 +16,13 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.Inter; -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JFormattedTextField; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JRadioButton; -import javax.swing.JSeparator; -import javax.swing.JSpinner; -import javax.swing.SpinnerNumberModel; +import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.basic.BasicSliderUI; import javax.swing.text.DefaultFormatterFactory; import javax.swing.text.NumberFormatter; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.EventQueue; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Point; -import java.awt.Rectangle; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -54,30 +35,25 @@ import java.math.BigDecimal; */ public class JSliderPane extends JPanel { + public static final Image APPFIT_V0 = BaseUtils.readImage("com/fr/design/images/control/icon_thumb_normal.png"); private static final double ONEPOINTEIGHT = 1.8; private static final int SIX = 6; private static final int TEN = 10; - private static final int ONE_EIGHT = 18; private static final int FONT_SIZE = 12; private static final int SPINNER_WIDTH = 45; private static final int SPINNER_HEIGHT = 20; private static final int HALF_HUNDRED = 50; private static final int HUNDRED = 100; private static final int TWO_HUNDRED = 200; - private static final int THREE_HUNDRED = 300; private static final int FOUR_HUNDRED = 400; - private static final int DIALOG_WIDTH = 157; - private static final int DIALOG_HEIGHT = 192; - private static final int SLIDER_WIDTH = 220; - private static final int SLIDER_HEIGHT = 20; private static final int SHOWVALBUTTON_WIDTH = 40; private static final int SHOWVALBUTTON_HEIGHTH = 20; - private static final int SLIDER_GAP = 5; private static final int TOOLTIP_Y = 30; private static final Color BACK_COLOR = new Color(245, 245, 247); public int showValue = 100; public double resolutionTimes = 1.0; + private static JSliderPane THIS; private UITextField showVal; private JSpinner showValSpinner; private UISlider slider; @@ -88,14 +64,12 @@ public class JSliderPane extends JPanel { private UISliderButton showValButton; private UIRadioButton twoHundredButton; private UIRadioButton oneHundredButton; - private UIRadioButton sevenFiveButton; + private UIRadioButton SevenFiveButton; private UIRadioButton fiveTenButton; private UIRadioButton twoFiveButton; private UIRadioButton selfAdaptButton; private UIRadioButton customButton; - /** - * 拖动条处理和button、直接输入不一样 - */ + //拖动条处理和button、直接输入不一样 private boolean isButtonOrIsTxt = true; private PopupPane dialog; private int upButtonX; @@ -111,7 +85,7 @@ public class JSliderPane extends JPanel { showValSpinner.setEditor(editor); JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField(); textField.setEditable(true); - DefaultFormatterFactory factory = (DefaultFormatterFactory) textField.getFormatterFactory(); + DefaultFormatterFactory factory = (DefaultFormatterFactory) textField .getFormatterFactory(); NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter(); formatter.setAllowsInvalid(false); @@ -119,7 +93,7 @@ public class JSliderPane extends JPanel { initShowValButton(); initUIRadioButton(); initPane(); - JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); + JPanel panel = new JPanel(new FlowLayout(1, 0, 0)); panel.add(downButton); panel.add(slider); panel.add(upButton); @@ -129,8 +103,12 @@ public class JSliderPane extends JPanel { } - public static JSliderPane getInstance() { - return new JSliderPane(); + public static final JSliderPane getInstance() { +// if (THIS == null) { +// THIS = new JSliderPane(); +// } + THIS = new JSliderPane(); + return THIS; } private void initSlider() { @@ -194,7 +172,7 @@ public class JSliderPane extends JPanel { private void initUIRadioButton() { twoHundredButton = new UIRadioButton("200%"); oneHundredButton = new UIRadioButton("100%"); - sevenFiveButton = new UIRadioButton("75%"); + SevenFiveButton = new UIRadioButton("75%"); fiveTenButton = new UIRadioButton("50%"); twoFiveButton = new UIRadioButton("25%"); selfAdaptButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_selfAdaptButton")); @@ -203,7 +181,7 @@ public class JSliderPane extends JPanel { customButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE)); twoHundredButton.addItemListener(radioButtonItemListener); oneHundredButton.addItemListener(radioButtonItemListener); - sevenFiveButton.addItemListener(radioButtonItemListener); + SevenFiveButton.addItemListener(radioButtonItemListener); fiveTenButton.addItemListener(radioButtonItemListener); twoFiveButton.addItemListener(radioButtonItemListener); customButton.addItemListener(new ItemListener() { @@ -221,7 +199,7 @@ public class JSliderPane extends JPanel { ButtonGroup bg = new ButtonGroup();// 初始化按钮组 bg.add(twoHundredButton);// 加入按钮组 bg.add(oneHundredButton); - bg.add(sevenFiveButton); + bg.add(SevenFiveButton); bg.add(fiveTenButton); bg.add(twoFiveButton); bg.add(selfAdaptButton); @@ -244,7 +222,7 @@ public class JSliderPane extends JPanel { septPane.setBackground(BACK_COLOR); twoHundredButton.setBackground(BACK_COLOR); oneHundredButton.setBackground(BACK_COLOR); - sevenFiveButton.setBackground(BACK_COLOR); + SevenFiveButton.setBackground(BACK_COLOR); fiveTenButton.setBackground(BACK_COLOR); twoFiveButton.setBackground(BACK_COLOR); selfAdaptButton.setBackground(BACK_COLOR); @@ -254,7 +232,7 @@ public class JSliderPane extends JPanel { new Component[]{septPane, null}, new Component[]{twoHundredButton, null}, new Component[]{oneHundredButton, null}, - new Component[]{sevenFiveButton, null}, + new Component[]{SevenFiveButton, null}, new Component[]{fiveTenButton, null}, new Component[]{twoFiveButton, null}, new Component[]{selfAdaptButton, null}, @@ -275,14 +253,14 @@ public class JSliderPane extends JPanel { return spinnerPanel; } - private ActionListener showValButtonActionListener = new ActionListener() { + ActionListener showValButtonActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { popupDialog(); } }; - private ChangeListener showValSpinnerChangeListener = new ChangeListener() { + ChangeListener showValSpinnerChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int val = (int) ((UIBasicSpinner) e.getSource()).getValue(); @@ -305,7 +283,7 @@ public class JSliderPane extends JPanel { //定义一个监听器,用于监听所有滑动条 - private ChangeListener listener = new ChangeListener() { + ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent event) { //取出滑动条的值,并在文本中显示出来 if (!isButtonOrIsTxt) { @@ -325,7 +303,7 @@ public class JSliderPane extends JPanel { } }; - private ItemListener radioButtonItemListener = new ItemListener() { + ItemListener radioButtonItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { JRadioButton temp = (JRadioButton) e.getSource(); @@ -341,7 +319,7 @@ public class JSliderPane extends JPanel { slider.setValue((int) (showValue + TWO_HUNDRED) / SIX); } else if (showValue < HUNDRED) { slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT)); - } else { + } else if (showValue == HUNDRED) { slider.setValue(HALF_HUNDRED); } } @@ -359,7 +337,7 @@ public class JSliderPane extends JPanel { return this.showValue; } - public void reset() { + public void reset(){ this.showValSpinner.setValue(HUNDRED); } @@ -369,7 +347,7 @@ public class JSliderPane extends JPanel { return b1.divide(b2, scale).doubleValue(); } - private ActionListener buttonActionListener = new ActionListener() { + ActionListener buttonActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showValue = (int) showValSpinner.getValue(); @@ -406,7 +384,7 @@ public class JSliderPane extends JPanel { } else if (value < HALF_HUNDRED) { times = (int) Math.round(ONEPOINTEIGHT * value + TEN); } else { - times = SIX * value - TWO_HUNDRED; + times = (int) (SIX * value - TWO_HUNDRED); } } @@ -425,14 +403,14 @@ public class JSliderPane extends JPanel { dialog = new PopupPane(upButton, dialogContentPanel); if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); } } else { if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); } else { - GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); } } } @@ -453,8 +431,8 @@ public class JSliderPane extends JPanel { class JSliderPaneUI extends BasicSliderUI { private static final Color BACK_COLOR = new Color(245, 245, 247); - private static final int VERTICAL_WIDTH = 11; - private static final int VERTICAL_HEIGHT = 16; + private static final int THUMB_XOFFSET = 8; + private static final int THUMB_YOFFSET = 3; private static final int FOUR = 4; private static final int FIVE = 5; private static final int SIX = 6; @@ -464,20 +442,19 @@ class JSliderPaneUI extends BasicSliderUI { super(b); } + /** */ /** * 绘制指示物 */ + public void paintThumb(Graphics g) { Rectangle knobBounds = thumbRect; - int w = knobBounds.width; - int h = knobBounds.height; Graphics2D g2d = (Graphics2D) g; - - g2d.translate(knobBounds.x, knobBounds.y); - g2d.setColor(new Color(51, 51, 52)); - g2d.fillRoundRect(0, SIX, FOUR, 9, 2, 2); + g2d.drawImage(JSliderPane.APPFIT_V0, knobBounds.x - THUMB_XOFFSET, knobBounds.y + THUMB_YOFFSET, null); + g2d.dispose(); } + /** */ /** * 绘制刻度轨迹 */ @@ -498,11 +475,19 @@ class JSliderPaneUI extends BasicSliderUI { } } + public void setThumbLocation(int x, int y) { + super.setThumbLocation(x, y); + slider.repaint(); + } + } -class PopupPane extends JPopupMenu { +class PopupPane extends UIPopupMenu { + private static final float REC = 8f; + private static final int INSERT_TOPBOTTOM = 10; + private static final int INSERT_LEFTRIGHT = 2; private static final int DIALOG_WIDTH = 157; - private static final int DIALOG_HEIGHT = 192; + private static final int DIALOG_HEIGHT = 205; PopupPane(JButton b, JPanel dialogContentPanel) { this.add(dialogContentPanel, BorderLayout.CENTER); @@ -510,5 +495,7 @@ class PopupPane extends JPopupMenu { this.setBackground(new Color(245, 245, 247)); } - + public Insets getInsets() { + return new Insets(INSERT_TOPBOTTOM, INSERT_LEFTRIGHT, INSERT_TOPBOTTOM, INSERT_LEFTRIGHT); + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index 2e6d82fb3d..c6b8381472 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -1,5 +1,5 @@ /** - * + * */ package com.fr.design.designer.creator.cardlayout; @@ -15,34 +15,43 @@ import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WBorderLayout; +import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; +import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.general.Inter; - -import java.awt.*; +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Component; +import java.awt.Composite; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.util.ArrayList; +import java.util.List; /** * card布局主体框架 - * + * * * * @date: 2014-12-9-下午9:59:31 */ public class XWCardMainBorderLayout extends XWBorderLayout{ - + private static final int CENTER = 1; private static final int NORTH = 0; - public static final Color DEFAULT_BORDER_COLOR = new Color(210,210,210); - private static final int LAYOUT_INDEX = 0; private static final int TITLE_STYLE = 2; - private static final int NORMAL_STYLE = 1; private static final int EDIT_BTN_WIDTH = 60; private static final int EDIT_BTN_HEIGHT = 24; - + + private final int CARDMAINLAYOUT_CHILD_COUNT = 1; + /** * 构造函数 */ @@ -52,38 +61,65 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ /** * 获取当前组件里的控件 - * + * * @return 控件 - * + * * * @date 2014-12-10-下午1:46:33 - * + * */ + @Override public WCardMainBorderLayout toData() { return (WCardMainBorderLayout) super.toData(); } - + /** * 添加标题区域 - * + * * @param title 标题区域 - * + * * * @date 2014-12-10-下午1:50:56 - * + * */ - public void addTitlePart(XWCardTitleLayout title){ - this.add(title, WBorderLayout.NORTH); + public void addTitlePart(XWCardTitleLayout title, String position){ + toData().setTabPosition(position); + this.add(title, position); } - + + public int getTitleWidth(){ + String position = toData().getTabPosition(); + if(ComparatorUtils.equals(WBorderLayout.NORTH, position) || ComparatorUtils.equals(WBorderLayout.SOUTH, position)){ + return getTitlePart().getHeight(); + } + return getTitlePart().getWidth(); + } + + public void add(Component comp, String position) { + super.add(comp, position); + } + + + /** + * 切换到非添加状态 + * + * @return designer 表单设计器 + */ + @Override + public void stopAddingState(FormDesigner designer){ + designer.stopAddingState(); + return; + } + + /** * 添加card区域 - * + * * @param card card区域 - * + * * * @date 2014-12-10-下午1:50:37 - * + * */ public void addCardPart(XWCardLayout card){ this.add(card, WBorderLayout.CENTER); @@ -92,11 +128,17 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ public XWCardLayout getCardPart(){ return this.getComponentCount() == TITLE_STYLE ? (XWCardLayout)this.getComponent(CENTER) : (XWCardLayout)this.getComponent(NORTH); } - + public XWCardTitleLayout getTitlePart(){ + Component[] components = this.getComponents(); + for(Component component : components){ + if(component instanceof XWCardTitleLayout){ + return (XWCardTitleLayout)component; + } + } return (XWCardTitleLayout)this.getComponent(NORTH); } - + /** * 控件树里需要隐藏xwcardmainLayout,返回其子组件xwcardLayout; * 标题样式下,this.getComponent(1)==xwcardLayout @@ -105,23 +147,23 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ */ @Override public XCreator getXCreator() { - switch(this.getComponentCount()){ - case TITLE_STYLE: - return (XCreator)this.getComponent(TITLE_STYLE-1); - case NORMAL_STYLE: - return (XCreator)this.getComponent(NORMAL_STYLE-1); - default: - return this; - } + return this; } + /** * 控件树不显示此组件 * @param path 控件树list */ - public void notShowInComponentTree(ArrayList path) { - path.remove(LAYOUT_INDEX); + @Override + public void notShowInComponentTree(List path) { + return; } - + + @Override + public int getShowXCreatorCount() { + return CARDMAINLAYOUT_CHILD_COUNT; + } + @Override public ArrayList getTargetChildrenList() { ArrayList tabLayoutList = new ArrayList(); @@ -132,12 +174,13 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ } return tabLayoutList; } - + /** * 重新调整子组件的宽度 * @param width 宽度 */ - public void recalculateChildWidth(int width){ + @Override + public void recalculateChildWidth(int width){ ArrayList childrenList = this.getTargetChildrenList(); int size = childrenList.size(); if (size > 0) { @@ -163,12 +206,13 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ } } } - + /** * 重新调整子组件的高度 * @param height 高度 */ - public void recalculateChildHeight(int height){ + @Override + public void recalculateChildHeight(int height){ ArrayList childrenList = this.getTargetChildrenList(); int size = childrenList.size(); if (size > 0) { @@ -197,9 +241,10 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ tabLayout.adjustCreatorsHeight(percent); } } - + } + @Override public void paint(Graphics g) { super.paint(g); //如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层 @@ -242,10 +287,12 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ * @param editingMouseListener 鼠标点击,位置处理器 * @param e 鼠标点击事件 */ - public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ + @Override + public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e){ FormDesigner designer = editingMouseListener.getDesigner(); SelectionModel selectionModel = editingMouseListener.getSelectionModel(); - boolean isEditing = designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2; + boolean isEditing = e.getButton() == MouseEvent.BUTTON1 && + (designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2); setEditable(isEditing); selectionModel.selectACreatorAtMouseEvent(e); @@ -274,10 +321,48 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ } } + @Override + public int getIndexOfChild(Object child) { + XWCardTitleLayout titlePart = this.getTitlePart(); + return titlePart.getIndexOfChild(child); + } + /** * data属性改变触发其他操作 * */ + @Override public void firePropertyChange(){ + getCardPart().initStyle(); + } + + + public void resetTabDisplayPosition(WTabDisplayPosition wTabDisplayPosition){ + XWCardTitleLayout xwCardTitleLayout = getTitlePart(); + int titleSize = getTitleWidth(); + xwCardTitleLayout.resetNewBtnPosition(wTabDisplayPosition); + Rectangle parentBounds = new Rectangle(xwCardTitleLayout.getBounds()); + switch (wTabDisplayPosition){ + case TOP_POSITION: + this.addTitlePart(xwCardTitleLayout,WBorderLayout.NORTH); + parentBounds.height = titleSize; + break; + case LEFT_POSITION: + this.addTitlePart(xwCardTitleLayout,WBorderLayout.WEST); + parentBounds.width = titleSize; + break; + case BOTTOM_POSITION: + this.addTitlePart(xwCardTitleLayout,WBorderLayout.SOUTH); + parentBounds.height = titleSize; + break; + case RIGHT_POSITION: + this.addTitlePart(xwCardTitleLayout,WBorderLayout.EAST); + parentBounds.width = titleSize; + break; + default: + break; + } + xwCardTitleLayout.setBounds(parentBounds); + this.addCardPart((XWCardLayout)this.getComponent(0)); } } \ No newline at end of file