plough 8 years ago
parent
commit
395f78d2e2
  1. 183
      designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java

183
designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java

@ -18,7 +18,6 @@ import com.fr.form.ui.*;
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;
import com.fr.stable.OperatingSystem;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -27,7 +26,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
public class FormParaWidgetPane extends JPanel{ public class FormParaWidgetPane extends JPanel {
private static FormParaWidgetPane THIS; private static FormParaWidgetPane THIS;
private List<WidgetOption> predifinedwidgeList = new ArrayList<WidgetOption>(); private List<WidgetOption> predifinedwidgeList = new ArrayList<WidgetOption>();
@ -46,19 +45,19 @@ public class FormParaWidgetPane extends JPanel{
//预定义控件最多显示20行 //预定义控件最多显示20行
private int preWidgetShowMaxRow = 20; private int preWidgetShowMaxRow = 20;
//显示8个图表组件 //显示8个图表组件
private static final int commonChartNum = 8; private static final int COMMON_CHAR_NUM = 8;
//显示10个普通控件 //显示10个普通控件
private int commonWidgetNum = 10; private int commonWidgetNum = 10;
private JSeparator jSeparatorPara; private JSeparator jSeparatorPara;
private JSeparator jSeparatorChart; private JSeparator jSeparatorChart;
private JSeparator jSeparatorLayout; private JSeparator jSeparatorLayout;
private UILabel paraLabel ; private UILabel paraLabel;
private FormDesigner designer; private FormDesigner designer;
public static final FormParaWidgetPane getInstance(FormDesigner designer) { public static final FormParaWidgetPane getInstance(FormDesigner designer) {
if(THIS == null) { if (THIS == null) {
THIS = new FormParaWidgetPane(); THIS = new FormParaWidgetPane();
} }
THIS.designer = designer; THIS.designer = designer;
@ -71,13 +70,13 @@ public class FormParaWidgetPane extends JPanel{
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().addComponentListener(new ComponentAdapter() { DesignerContext.getDesignerFrame().getCenterTemplateCardPane().addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
if (FormParaWidgetPane.this.getParent() != null) { if (FormParaWidgetPane.this.getParent() != null) {
JPanel fother = (JPanel)FormParaWidgetPane.this.getParent(); JPanel fother = (JPanel) FormParaWidgetPane.this.getParent();
int delta_wdith = 0; int delta_wdith = 0;
for (int i = 0; i < fother.getComponentCount() - 1; i ++) { for (int i = 0; i < fother.getComponentCount() - 1; i++) {
delta_wdith += fother.getComponent(i).getWidth(); delta_wdith += fother.getComponent(i).getWidth();
} }
if(delta_wdith == 0){ if (delta_wdith == 0) {
return; return;
} }
@ -97,16 +96,16 @@ public class FormParaWidgetPane extends JPanel{
JPanel paraPane = new JPanel(new FlowLayout()); JPanel paraPane = new JPanel(new FlowLayout());
ToolBarButton paraButton = new paraButton(FormWidgetOption.PARAMETERCONTAINER); ToolBarButton paraButton = new paraButton(FormWidgetOption.PARAMETERCONTAINER);
paraPane.add(paraButton); paraPane.add(paraButton);
add(createNormalCombinationPane(paraPane,Inter.getLocText("FR-Designer_Parameter"))); add(createNormalCombinationPane(paraPane, Inter.getLocText("FR-Designer_Parameter")));
jSeparatorPara = createJSeparator(); jSeparatorPara = createJSeparator();
add(jSeparatorPara); add(jSeparatorPara);
JPanel layoutPane = new JPanel(new FlowLayout()); JPanel layoutPane = new JPanel(new FlowLayout());
for(WidgetOption option : loadLayoutOptions()){ for (WidgetOption option : loadLayoutOptions()) {
layoutPane.add(new ToolBarButton(option)); layoutPane.add(new ToolBarButton(option));
} }
layoutPane.add(new ToolBarButton(FormWidgetOption.ELEMENTCASE)); layoutPane.add(new ToolBarButton(FormWidgetOption.ELEMENTCASE));
add(createNormalCombinationPane(layoutPane,Inter.getLocText("FR-Designer_Layout_Block_Blank"))); add(createNormalCombinationPane(layoutPane, Inter.getLocText("FR-Designer_Layout_Block_Blank")));
jSeparatorLayout = createJSeparator(); jSeparatorLayout = createJSeparator();
add(jSeparatorLayout); add(jSeparatorLayout);
@ -114,8 +113,8 @@ public class FormParaWidgetPane extends JPanel{
int totalChartNums = loadChartOptions().length; int totalChartNums = loadChartOptions().length;
if (totalChartNums > 0) { if (totalChartNums > 0) {
JPanel chartTypePane = new JPanel(new FlowLayout()); JPanel chartTypePane = new JPanel(new FlowLayout());
for (int i = 0;i < commonChartNum ;i++) { for (int i = 0; i < COMMON_CHAR_NUM; i++) {
chartTypePane.add( new ToolBarButton(loadChartOptions()[i])); chartTypePane.add(new ToolBarButton(loadChartOptions()[i]));
} }
add(createChartCombinationPane(chartTypePane, Inter.getLocText("FR-Designer-Form-ToolBar_Chart"))); add(createChartCombinationPane(chartTypePane, Inter.getLocText("FR-Designer-Form-ToolBar_Chart")));
jSeparatorChart = createJSeparator(); jSeparatorChart = createJSeparator();
@ -123,13 +122,13 @@ public class FormParaWidgetPane extends JPanel{
} }
JPanel widgetPane = new JPanel(new FlowLayout()); JPanel widgetPane = new JPanel(new FlowLayout());
for (int i = 0;i < commonWidgetNum;i++) { for (int i = 0; i < commonWidgetNum; i++) {
widgetPane.add(new ToolBarButton(loadWidgetOptions()[i])); widgetPane.add(new ToolBarButton(loadWidgetOptions()[i]));
} }
widgetPane.add(createJSeparator(20)); widgetPane.add(createJSeparator(20));
loadPredefinedWidget(); loadPredefinedWidget();
int num = Math.min(predifinedwidgeList.size(),preWidgetShowMaxNum); int num = Math.min(predifinedwidgeList.size(), preWidgetShowMaxNum);
for (int i = 0 ;i < num ;i++) { for (int i = 0; i < num; i++) {
widgetPane.add(new ToolBarButton(predifinedwidgeList.get(i))); widgetPane.add(new ToolBarButton(predifinedwidgeList.get(i)));
} }
add(createWidgetCombinationPane(widgetPane, Inter.getLocText("FR-Designer-Form-ToolBar_Widget"))); add(createWidgetCombinationPane(widgetPane, Inter.getLocText("FR-Designer-Form-ToolBar_Widget")));
@ -138,9 +137,9 @@ public class FormParaWidgetPane extends JPanel{
private void loadPredefinedWidget() { private void loadPredefinedWidget() {
predifinedwidgeList.clear(); predifinedwidgeList.clear();
if(designer != null) { if (designer != null) {
WidgetOption[] designerPre = designer.getDesignerMode().getPredefinedWidgetOptions(); WidgetOption[] designerPre = designer.getDesignerMode().getPredefinedWidgetOptions();
for(int i = 0; i < designerPre.length; i++) { for (int i = 0; i < designerPre.length; i++) {
predifinedwidgeList.add(designerPre[i]); predifinedwidgeList.add(designerPre[i]);
} }
} }
@ -156,7 +155,7 @@ public class FormParaWidgetPane extends JPanel{
// ... // ...
continue; continue;
} }
if (!XCreatorUtils.createXCreator(widget).canEnterIntoParaPane()){ if (!XCreatorUtils.createXCreator(widget).canEnterIntoParaPane()) {
//预定义控件工具栏这儿不显示工具栏中没有的预定义控件 //预定义控件工具栏这儿不显示工具栏中没有的预定义控件
continue; continue;
} }
@ -177,61 +176,59 @@ public class FormParaWidgetPane extends JPanel{
} }
private JPanel createNormalCombinationPane(JComponent jComponent,String typeName){ private JPanel createNormalCombinationPane(JComponent jComponent, String typeName) {
JPanel reportPane = new JPanel(new BorderLayout(17,5)); JPanel reportPane = new JPanel(new BorderLayout(17, 5));
reportPane.add(jComponent,BorderLayout.CENTER); reportPane.add(jComponent, BorderLayout.CENTER);
JPanel labelPane = new JPanel(new BorderLayout()); JPanel labelPane = new JPanel(new BorderLayout());
UILabel label = new UILabel(typeName,UILabel.CENTER); UILabel label = new UILabel(typeName, UILabel.CENTER);
if(ComparatorUtils.equals(Inter.getLocText("FR-Designer_Parameter"),typeName )){ if (ComparatorUtils.equals(Inter.getLocText("FR-Designer_Parameter"), typeName)) {
paraLabel = label; paraLabel = label;
} }
labelPane.add(label,BorderLayout.CENTER); labelPane.add(label, BorderLayout.CENTER);
reportPane.add(labelPane,BorderLayout.SOUTH); reportPane.add(labelPane, BorderLayout.SOUTH);
reportPane.setPreferredSize(new Dimension((int)reportPane.getPreferredSize().getWidth(),(int)reportPane.getPreferredSize().getHeight())); reportPane.setPreferredSize(new Dimension((int) reportPane.getPreferredSize().getWidth(), (int) reportPane.getPreferredSize().getHeight()));
return reportPane; return reportPane;
} }
private JPanel createChartCombinationPane(JComponent jComponent,String typeName){ private JPanel createChartCombinationPane(JComponent jComponent, String typeName) {
JPanel chartPane = new JPanel(new BorderLayout(17,5)); JPanel chartPane = new JPanel(new BorderLayout(17, 5));
chartPane.add(jComponent, BorderLayout.CENTER); chartPane.add(jComponent, BorderLayout.CENTER);
JPanel labelPane = new JPanel(new BorderLayout()); JPanel labelPane = new JPanel(new BorderLayout());
labelPane.add(new UILabel(typeName,UILabel.CENTER),BorderLayout.CENTER); labelPane.add(new UILabel(typeName, UILabel.CENTER), BorderLayout.CENTER);
UIButton chartPopUpButton = createPopUpButton(); UIButton chartPopUpButton = createPopUpButton();
chartPopUpButton.addMouseListener(new MouseAdapter() { chartPopUpButton.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if(chartTypeWindow == null) {
JPanel componentsPara = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel componentsPara = new JPanel(new FlowLayout(FlowLayout.LEFT));
WidgetOption[] chartOptions = loadChartOptions(); WidgetOption[] chartOptions = loadChartOptions();
for (WidgetOption chartOption : chartOptions) { for (WidgetOption chartOption : chartOptions) {
componentsPara.add( new ToolBarButton(chartOption)); componentsPara.add(new ToolBarButton(chartOption));
} }
int x = commonChartNum * (widgetButtonWidth + smallGAP); int x = COMMON_CHAR_NUM * (widgetButtonWidth + smallGAP);
int y = (int)Math.ceil(chartOptions.length/((double)commonChartNum)) * (widgetButtonHeight + smallGAP); int y = (int) Math.ceil(chartOptions.length / ((double) COMMON_CHAR_NUM)) * (widgetButtonHeight + smallGAP);
componentsPara.setPreferredSize(new Dimension(x,y)); componentsPara.setPreferredSize(new Dimension(x, y));
chartTypeWindow = new PopUpWindow(componentsPara, Inter.getLocText("FR-Designer-Form-ToolBar_Chart")); chartTypeWindow = new PopUpWindow(componentsPara, Inter.getLocText("FR-Designer-Form-ToolBar_Chart"));
chartTypeWindow.setLocation((int)jSeparatorLayout.getLocationOnScreen().getX() + 1, (int)jSeparatorLayout.getLocationOnScreen().getY()); chartTypeWindow.setLocation((int) jSeparatorLayout.getLocationOnScreen().getX() + 1, (int) jSeparatorLayout.getLocationOnScreen().getY());
chartTypeWindow.setSize(chartTypeWindow.getPreferredSize()); chartTypeWindow.setSize(chartTypeWindow.getPreferredSize());
}
chartTypeWindow.setVisible(true); chartTypeWindow.setVisible(true);
} }
}); });
labelPane.add(chartPopUpButton,BorderLayout.EAST); labelPane.add(chartPopUpButton, BorderLayout.EAST);
chartPane.add(labelPane,BorderLayout.SOUTH); chartPane.add(labelPane, BorderLayout.SOUTH);
return chartPane; return chartPane;
} }
private JPanel createWidgetCombinationPane(JComponent jComponent,String typeName){ private JPanel createWidgetCombinationPane(JComponent jComponent, String typeName) {
JPanel widgetPane = new JPanel(new BorderLayout(17,5)); JPanel widgetPane = new JPanel(new BorderLayout(17, 5));
widgetPane.add(jComponent,BorderLayout.CENTER); widgetPane.add(jComponent, BorderLayout.CENTER);
JPanel labelPane = new JPanel(new BorderLayout()); JPanel labelPane = new JPanel(new BorderLayout());
labelPane.add(new UILabel(typeName,UILabel.CENTER),BorderLayout.CENTER); labelPane.add(new UILabel(typeName, UILabel.CENTER), BorderLayout.CENTER);
UIButton chartPopUpButton = createPopUpButton(); UIButton chartPopUpButton = createPopUpButton();
chartPopUpButton.addMouseListener(new MouseAdapter() { chartPopUpButton.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
JPanel widgetPane = new JPanel(new FlowLayout(FlowLayout.LEFT,0,0)); JPanel widgetPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
loadPredefinedWidget(); loadPredefinedWidget();
int rowNum = calculateWidgetWindowRowNum(); int rowNum = calculateWidgetWindowRowNum();
JPanel westPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel westPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
@ -239,27 +236,27 @@ public class FormParaWidgetPane extends JPanel{
westPanel.add(new ToolBarButton(o)); westPanel.add(new ToolBarButton(o));
} }
int x = commonWidgetNum * (widgetButtonWidth + smallGAP); int x = commonWidgetNum * (widgetButtonWidth + smallGAP);
westPanel.setPreferredSize(new Dimension(x,(int)(rowNum * westPanel.getPreferredSize().getHeight()))); westPanel.setPreferredSize(new Dimension(x, (int) (rowNum * westPanel.getPreferredSize().getHeight())));
JPanel eastPane = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel eastPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
for (WidgetOption no : predifinedwidgeList) { for (WidgetOption no : predifinedwidgeList) {
eastPane.add(new ToolBarButton(no)); eastPane.add(new ToolBarButton(no));
} }
int maxWidth = preWidgetShowMaxNum * (widgetButtonWidth + smallGAP); int maxWidth = preWidgetShowMaxNum * (widgetButtonWidth + smallGAP);
int width = predifinedwidgeList.size() >= preWidgetShowMaxNum ? maxWidth:(int)eastPane.getPreferredSize().getWidth(); int width = predifinedwidgeList.size() >= preWidgetShowMaxNum ? maxWidth : (int) eastPane.getPreferredSize().getWidth();
eastPane.setPreferredSize(new Dimension(width,(int)(rowNum*eastPane.getPreferredSize().getHeight()))); eastPane.setPreferredSize(new Dimension(width, (int) (rowNum * eastPane.getPreferredSize().getHeight())));
UIScrollPane eastScrollPane = new UIScrollPane(eastPane); UIScrollPane eastScrollPane = new UIScrollPane(eastPane);
eastScrollPane.setBorder(null); eastScrollPane.setBorder(null);
int maxHeight = preWidgetShowMaxRow * (widgetButtonHeight + smallGAP); int maxHeight = preWidgetShowMaxRow * (widgetButtonHeight + smallGAP);
int height = predifinedwidgeList.size() >= preWidgetShowMaxNum * preWidgetShowMaxRow ? maxHeight : (int)eastPane.getPreferredSize().getHeight(); int height = predifinedwidgeList.size() >= preWidgetShowMaxNum * preWidgetShowMaxRow ? maxHeight : (int) eastPane.getPreferredSize().getHeight();
width = predifinedwidgeList.size() >= preWidgetShowMaxNum * preWidgetShowMaxRow ? (int)eastPane.getPreferredSize().getWidth() + smallGAP + jsparatorWidth : (int)eastPane.getPreferredSize().getWidth(); width = predifinedwidgeList.size() >= preWidgetShowMaxNum * preWidgetShowMaxRow ? (int) eastPane.getPreferredSize().getWidth() + smallGAP + jsparatorWidth : (int) eastPane.getPreferredSize().getWidth();
eastScrollPane.setPreferredSize(new Dimension(width,height)); eastScrollPane.setPreferredSize(new Dimension(width, height));
widgetPane.add(westPanel); widgetPane.add(westPanel);
widgetPane.add(createJSeparator(height)); widgetPane.add(createJSeparator(height));
widgetPane.add(eastScrollPane); widgetPane.add(eastScrollPane);
widgetTypeWindow = new PopUpWindow( widgetPane, Inter.getLocText("FR-Designer-Form-ToolBar_Widget")); widgetTypeWindow = new PopUpWindow(widgetPane, Inter.getLocText("FR-Designer-Form-ToolBar_Widget"));
widgetTypeWindow.setSize(widgetTypeWindow.getPreferredSize()); widgetTypeWindow.setSize(widgetTypeWindow.getPreferredSize());
if (jSeparatorChart != null) { if (jSeparatorChart != null) {
widgetTypeWindow.setLocation((int) jSeparatorChart.getLocationOnScreen().getX() + 1, (int) jSeparatorChart.getLocationOnScreen().getY()); widgetTypeWindow.setLocation((int) jSeparatorChart.getLocationOnScreen().getX() + 1, (int) jSeparatorChart.getLocationOnScreen().getY());
@ -268,59 +265,60 @@ public class FormParaWidgetPane extends JPanel{
} }
}); });
labelPane.add(chartPopUpButton,BorderLayout.EAST); labelPane.add(chartPopUpButton, BorderLayout.EAST);
widgetPane.add(labelPane,BorderLayout.SOUTH); widgetPane.add(labelPane, BorderLayout.SOUTH);
return widgetPane; return widgetPane;
} }
private int calculateWidgetWindowRowNum(){ private int calculateWidgetWindowRowNum() {
//向上取整 //向上取整
int rowNum = (int)Math.ceil((double)predifinedwidgeList.size()/(double)preWidgetShowMaxNum); int rowNum = (int) Math.ceil((double) predifinedwidgeList.size() / (double) preWidgetShowMaxNum);
rowNum = Math.max(rowNum,2); rowNum = Math.max(rowNum, 2);
rowNum = Math.min(rowNum,preWidgetShowMaxRow); rowNum = Math.min(rowNum, preWidgetShowMaxRow);
return rowNum; return rowNum;
} }
private JSeparator createJSeparator(){ private JSeparator createJSeparator() {
JSeparator jSeparator = new JSeparator(SwingConstants.VERTICAL ); JSeparator jSeparator = new JSeparator(SwingConstants.VERTICAL);
jSeparator.setPreferredSize(new Dimension(jsparatorWidth,jsparatorHeight)); jSeparator.setPreferredSize(new Dimension(jsparatorWidth, jsparatorHeight));
return jSeparator; return jSeparator;
} }
private JSeparator createJSeparator(double height){ private JSeparator createJSeparator(double height) {
JSeparator jSeparator = new JSeparator(SwingConstants.VERTICAL ); JSeparator jSeparator = new JSeparator(SwingConstants.VERTICAL);
jSeparator.setPreferredSize(new Dimension(jsparatorWidth,(int)height)); jSeparator.setPreferredSize(new Dimension(jsparatorWidth, (int) height));
return jSeparator; return jSeparator;
} }
private UIButton createPopUpButton(){ private UIButton createPopUpButton() {
UIButton popUpButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowdown.png")); UIButton popUpButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowdown.png"));
popUpButton.set4ToolbarButton(); popUpButton.set4ToolbarButton();
return popUpButton; return popUpButton;
} }
private UIButton createPopDownButton(){ private UIButton createPopDownButton() {
UIButton popUpButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowup.png")); UIButton popUpButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowup.png"));
popUpButton.set4ToolbarButton(); popUpButton.set4ToolbarButton();
return popUpButton; return popUpButton;
} }
private class paraButton extends ToolBarButton{ private class paraButton extends ToolBarButton {
public paraButton(WidgetOption no){ public paraButton(WidgetOption no) {
super(no); super(no);
this.setDisabledIcon(BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_parameter2.png")); this.setDisabledIcon(BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_parameter2.png"));
if(designer != null){ if (designer != null) {
this.setEnabled(designer.getParaComponent() == null); this.setEnabled(designer.getParaComponent() == null);
} }
} }
public void mouseDragged(MouseEvent e) { public void mouseDragged(MouseEvent e) {
if (designer.getParaComponent() != null){ if (designer.getParaComponent() != null) {
return; return;
} }
designer.addParaComponent(); designer.addParaComponent();
JPanel pane =FormWidgetDetailPane.getInstance(designer); JPanel pane = FormWidgetDetailPane.getInstance(designer);
EastRegionContainerPane.getInstance().replaceDownPane(pane); EastRegionContainerPane.getInstance().replaceDownPane(pane);
this.setEnabled(false); this.setEnabled(false);
@ -334,7 +332,7 @@ public class FormParaWidgetPane extends JPanel{
public void setEnabled(boolean b) { public void setEnabled(boolean b) {
super.setEnabled(b); super.setEnabled(b);
paraLabel.setForeground(b ? Color.BLACK : new Color(198,198,198)); paraLabel.setForeground(b ? Color.BLACK : new Color(198, 198, 198));
} }
} }
@ -348,6 +346,7 @@ public class FormParaWidgetPane extends JPanel{
/** /**
* 响应界面改变事件 * 响应界面改变事件
*
* @param evt 事件 * @param evt 事件
*/ */
public void fireCreatorModified(DesignerEvent evt) { public void fireCreatorModified(DesignerEvent evt) {
@ -356,14 +355,13 @@ public class FormParaWidgetPane extends JPanel{
} }
private class PopUpWindow extends JWindow { private class PopUpWindow extends JWindow {
private JPanel northPane; private JPanel northPane;
private String typeName; private String typeName;
private int LineWidth = 5; private int LineWidth = 5;
private int BarWidth = 10; private int BarWidth = 10;
public PopUpWindow(JPanel northPane,String typeName){ public PopUpWindow(JPanel northPane, String typeName) {
super(); super();
this.northPane = northPane; this.northPane = northPane;
this.typeName = typeName; this.typeName = typeName;
@ -376,21 +374,18 @@ public class FormParaWidgetPane extends JPanel{
public void eventDispatched(AWTEvent event) { public void eventDispatched(AWTEvent event) {
if (event instanceof MouseEvent) { if (event instanceof MouseEvent) {
MouseEvent mv = (MouseEvent) event; MouseEvent mv = (MouseEvent) event;
Point point = mv.getLocationOnScreen(); if (mv.getClickCount() > 0) {
double endX = PopUpWindow.this.getX() + northPane.getWidth() + LineWidth; Point point = new Point((int) (mv.getLocationOnScreen().getX()), (int) mv.getLocationOnScreen().getY());
double startX = endX - BarWidth; // 直接contains在mac下,点击内部也会消失
double startY = PopUpWindow.this.getY() + northPane.getY(); Dimension d = PopUpWindow.this.getSize();
double endY = startY + northPane.getHeight(); Point p = PopUpWindow.this.getLocation();
boolean dragBar = startX < point.getX() && endX > point.getX() && endY > point.getY(); Rectangle rect = new Rectangle(p, d);
if (!dragBar && mv.getClickCount() > 0 && mv.getID() != MouseEvent.MOUSE_RELEASED) { if (!rect.contains(point)) {
if(!ComparatorUtils.equals(mv.getSource(), PopUpWindow.this)) {
if (!OperatingSystem.isMacOS()) {
PopUpWindow.this.setVisible(false); PopUpWindow.this.setVisible(false);
} }
} }
} }
} }
}
}; };
@ -398,9 +393,9 @@ public class FormParaWidgetPane extends JPanel{
JPanel rootPane = new EditorChoosePane(); JPanel rootPane = new EditorChoosePane();
JPanel contentPane = new JPanel(); JPanel contentPane = new JPanel();
contentPane.setLayout(new BorderLayout(17, 0)); contentPane.setLayout(new BorderLayout(17, 0));
contentPane.add(northPane,BorderLayout.CENTER); contentPane.add(northPane, BorderLayout.CENTER);
JPanel labelPane = new JPanel(new BorderLayout()); JPanel labelPane = new JPanel(new BorderLayout());
labelPane.add(new UILabel(typeName,UILabel.CENTER),BorderLayout.CENTER); labelPane.add(new UILabel(typeName, UILabel.CENTER), BorderLayout.CENTER);
JButton popUpButton = createPopDownButton(); JButton popUpButton = createPopDownButton();
popUpButton.addMouseListener(new MouseAdapter() { popUpButton.addMouseListener(new MouseAdapter() {
@Override @Override
@ -409,8 +404,8 @@ public class FormParaWidgetPane extends JPanel{
} }
}); });
labelPane.add(popUpButton, BorderLayout.EAST); labelPane.add(popUpButton, BorderLayout.EAST);
contentPane.add(labelPane,BorderLayout.SOUTH); contentPane.add(labelPane, BorderLayout.SOUTH);
rootPane.add(contentPane,BorderLayout.CENTER); rootPane.add(contentPane, BorderLayout.CENTER);
return rootPane; return rootPane;
} }
@ -421,31 +416,31 @@ public class FormParaWidgetPane extends JPanel{
private class EditorChoosePane extends JPanel { private class EditorChoosePane extends JPanel {
public EditorChoosePane() { public EditorChoosePane() {
super(); super();
((FlowLayout)this.getLayout()).setVgap(1); ((FlowLayout) this.getLayout()).setVgap(1);
} }
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
Rectangle r = this.getBounds(); Rectangle r = this.getBounds();
g.setColor(UIConstants.NORMAL_BACKGROUND); g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillRoundRect(r.x, r.y, r.width, r.height,0,0); g.fillRoundRect(r.x, r.y, r.width, r.height, 0, 0);
g.setColor(UIConstants.LINE_COLOR); g.setColor(UIConstants.LINE_COLOR);
g.drawLine(r.x, r.y, r.x, r.y+r.height); g.drawLine(r.x, r.y, r.x, r.y + r.height);
g.drawLine(r.x, r.y+r.height-1, r.x+r.width-1, r.y+r.height-1); g.drawLine(r.x, r.y + r.height - 1, r.x + r.width - 1, r.y + r.height - 1);
g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1, r.y+r.height-1); g.drawLine(r.x + r.width - 1, r.y, r.x + r.width - 1, r.y + r.height - 1);
} }
} }
private WidgetOption[] loadWidgetOptions() { private WidgetOption[] loadWidgetOptions() {
if (widgetOptions == null) { if (widgetOptions == null) {
widgetOptions = (WidgetOption[])ArrayUtils.addAll(WidgetOption.getFormWidgetIntance(), ExtraDesignClassManager.getInstance().getFormWidgetOptions()); widgetOptions = (WidgetOption[]) ArrayUtils.addAll(WidgetOption.getFormWidgetIntance(), ExtraDesignClassManager.getInstance().getFormWidgetOptions());
} }
return widgetOptions; return widgetOptions;
} }
private WidgetOption[] loadLayoutOptions() { private WidgetOption[] loadLayoutOptions() {
if (layoutOptions == null) { if (layoutOptions == null) {
layoutOptions = (WidgetOption[])ArrayUtils.addAll(FormWidgetOption.getFormLayoutInstance(), ExtraDesignClassManager.getInstance().getFormWidgetContainerOptions()); layoutOptions = (WidgetOption[]) ArrayUtils.addAll(FormWidgetOption.getFormLayoutInstance(), ExtraDesignClassManager.getInstance().getFormWidgetContainerOptions());
} }
return layoutOptions; return layoutOptions;
} }

Loading…
Cancel
Save