|
|
|
@ -18,7 +18,6 @@ import com.fr.form.ui.*;
|
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
import com.fr.general.Inter; |
|
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
|
import com.fr.stable.OperatingSystem; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.awt.*; |
|
|
|
@ -46,7 +45,7 @@ public class FormParaWidgetPane extends JPanel{
|
|
|
|
|
//预定义控件最多显示20行
|
|
|
|
|
private int preWidgetShowMaxRow = 20; |
|
|
|
|
//显示8个图表组件
|
|
|
|
|
private static final int commonChartNum = 8; |
|
|
|
|
private static final int COMMON_CHAR_NUM = 8; |
|
|
|
|
//显示10个普通控件
|
|
|
|
|
private int commonWidgetNum = 10; |
|
|
|
|
private JSeparator jSeparatorPara; |
|
|
|
@ -114,7 +113,7 @@ public class FormParaWidgetPane extends JPanel{
|
|
|
|
|
int totalChartNums = loadChartOptions().length; |
|
|
|
|
if (totalChartNums > 0) { |
|
|
|
|
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])); |
|
|
|
|
} |
|
|
|
|
add(createChartCombinationPane(chartTypePane, Inter.getLocText("FR-Designer-Form-ToolBar_Chart"))); |
|
|
|
@ -201,19 +200,17 @@ public class FormParaWidgetPane extends JPanel{
|
|
|
|
|
chartPopUpButton.addMouseListener(new MouseAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
if(chartTypeWindow == null) { |
|
|
|
|
JPanel componentsPara = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
|
|
|
|
WidgetOption[] chartOptions = loadChartOptions(); |
|
|
|
|
for (WidgetOption chartOption : chartOptions) { |
|
|
|
|
componentsPara.add(new ToolBarButton(chartOption)); |
|
|
|
|
} |
|
|
|
|
int x = commonChartNum * (widgetButtonWidth + smallGAP); |
|
|
|
|
int y = (int)Math.ceil(chartOptions.length/((double)commonChartNum)) * (widgetButtonHeight + smallGAP); |
|
|
|
|
int x = COMMON_CHAR_NUM * (widgetButtonWidth + smallGAP); |
|
|
|
|
int y = (int) Math.ceil(chartOptions.length / ((double) COMMON_CHAR_NUM)) * (widgetButtonHeight + smallGAP); |
|
|
|
|
componentsPara.setPreferredSize(new Dimension(x, y)); |
|
|
|
|
chartTypeWindow = new PopUpWindow(componentsPara, Inter.getLocText("FR-Designer-Form-ToolBar_Chart")); |
|
|
|
|
chartTypeWindow.setLocation((int) jSeparatorLayout.getLocationOnScreen().getX() + 1, (int) jSeparatorLayout.getLocationOnScreen().getY()); |
|
|
|
|
chartTypeWindow.setSize(chartTypeWindow.getPreferredSize()); |
|
|
|
|
} |
|
|
|
|
chartTypeWindow.setVisible(true); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -314,6 +311,7 @@ public class FormParaWidgetPane extends JPanel{
|
|
|
|
|
this.setEnabled(designer.getParaComponent() == null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void mouseDragged(MouseEvent e) { |
|
|
|
|
if (designer.getParaComponent() != null) { |
|
|
|
|
return; |
|
|
|
@ -348,6 +346,7 @@ public class FormParaWidgetPane extends JPanel{
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 响应界面改变事件 |
|
|
|
|
* |
|
|
|
|
* @param evt 事件 |
|
|
|
|
*/ |
|
|
|
|
public void fireCreatorModified(DesignerEvent evt) { |
|
|
|
@ -356,7 +355,6 @@ public class FormParaWidgetPane extends JPanel{
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class PopUpWindow extends JWindow { |
|
|
|
|
private JPanel northPane; |
|
|
|
|
private String typeName; |
|
|
|
@ -376,21 +374,18 @@ public class FormParaWidgetPane extends JPanel{
|
|
|
|
|
public void eventDispatched(AWTEvent event) { |
|
|
|
|
if (event instanceof MouseEvent) { |
|
|
|
|
MouseEvent mv = (MouseEvent) event; |
|
|
|
|
Point point = mv.getLocationOnScreen(); |
|
|
|
|
double endX = PopUpWindow.this.getX() + northPane.getWidth() + LineWidth; |
|
|
|
|
double startX = endX - BarWidth; |
|
|
|
|
double startY = PopUpWindow.this.getY() + northPane.getY(); |
|
|
|
|
double endY = startY + northPane.getHeight(); |
|
|
|
|
boolean dragBar = startX < point.getX() && endX > point.getX() && endY > point.getY(); |
|
|
|
|
if (!dragBar && mv.getClickCount() > 0 && mv.getID() != MouseEvent.MOUSE_RELEASED) { |
|
|
|
|
if(!ComparatorUtils.equals(mv.getSource(), PopUpWindow.this)) { |
|
|
|
|
if (!OperatingSystem.isMacOS()) { |
|
|
|
|
if (mv.getClickCount() > 0) { |
|
|
|
|
Point point = new Point((int) (mv.getLocationOnScreen().getX()), (int) mv.getLocationOnScreen().getY()); |
|
|
|
|
// 直接contains在mac下,点击内部也会消失
|
|
|
|
|
Dimension d = PopUpWindow.this.getSize(); |
|
|
|
|
Point p = PopUpWindow.this.getLocation(); |
|
|
|
|
Rectangle rect = new Rectangle(p, d); |
|
|
|
|
if (!rect.contains(point)) { |
|
|
|
|
PopUpWindow.this.setVisible(false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|