|
|
@ -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,14 +26,14 @@ 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>(); |
|
|
|
|
|
|
|
|
|
|
|
private JWindow chartTypeWindow; |
|
|
|
private JWindow chartTypeWindow; |
|
|
|
private JWindow widgetTypeWindow; |
|
|
|
private JWindow widgetTypeWindow; |
|
|
|
private WidgetOption[] widgetOptions = null; |
|
|
|
private WidgetOption[] widgetOptions = null; |
|
|
|
private WidgetOption[] chartOptions = null; |
|
|
|
private WidgetOption[] chartOptions = null; |
|
|
|
private WidgetOption[] layoutOptions = null; |
|
|
|
private WidgetOption[] layoutOptions = null; |
|
|
|
private int widgetButtonWidth = 22; |
|
|
|
private int widgetButtonWidth = 22; |
|
|
|
private int widgetButtonHeight = 20; |
|
|
|
private int widgetButtonHeight = 20; |
|
|
@ -53,42 +52,42 @@ public class FormParaWidgetPane extends JPanel{ |
|
|
|
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; |
|
|
|
THIS.setTarget(designer); |
|
|
|
THIS.setTarget(designer); |
|
|
|
return THIS; |
|
|
|
return THIS; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public FormParaWidgetPane() { |
|
|
|
public FormParaWidgetPane() { |
|
|
|
setLayout(new FlowLayout(FlowLayout.LEFT)); |
|
|
|
setLayout(new FlowLayout(FlowLayout.LEFT)); |
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Dimension d = fother.getSize(); |
|
|
|
Dimension d = fother.getSize(); |
|
|
|
setPreferredSize(new Dimension(d.width - delta_wdith, d.height)); |
|
|
|
setPreferredSize(new Dimension(d.width - delta_wdith, d.height)); |
|
|
|
LayoutUtils.layoutContainer(fother); |
|
|
|
LayoutUtils.layoutContainer(fother); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
initFormParaComponent(); |
|
|
|
initFormParaComponent(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initFormParaComponent() { |
|
|
|
private void initFormParaComponent() { |
|
|
@ -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 < commonChartNum; 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,115 +122,115 @@ 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"))); |
|
|
|
add(createJSeparator()); |
|
|
|
add(createJSeparator()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
WidgetManagerProvider mgr = WidgetManager.getProviderInstance(); |
|
|
|
WidgetManagerProvider mgr = WidgetManager.getProviderInstance(); |
|
|
|
Iterator<String> nameIt = mgr.getWidgetConfigNameIterator(); |
|
|
|
Iterator<String> nameIt = mgr.getWidgetConfigNameIterator(); |
|
|
|
while (nameIt.hasNext()) { |
|
|
|
while (nameIt.hasNext()) { |
|
|
|
String name = nameIt.next(); |
|
|
|
String name = nameIt.next(); |
|
|
|
WidgetConfig widgetConfig = mgr.getWidgetConfig(name); |
|
|
|
WidgetConfig widgetConfig = mgr.getWidgetConfig(name); |
|
|
|
if (widgetConfig instanceof UserDefinedWidgetConfig) { |
|
|
|
if (widgetConfig instanceof UserDefinedWidgetConfig) { |
|
|
|
Widget widget = ((UserDefinedWidgetConfig) widgetConfig).getWidget(); |
|
|
|
Widget widget = ((UserDefinedWidgetConfig) widgetConfig).getWidget(); |
|
|
|
String widgetClassName = widget.getClass().getName(); |
|
|
|
String widgetClassName = widget.getClass().getName(); |
|
|
|
if (isButtonWidget(widgetClassName)) { |
|
|
|
if (isButtonWidget(widgetClassName)) { |
|
|
|
// ...
|
|
|
|
// ...
|
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!XCreatorUtils.createXCreator(widget).canEnterIntoParaPane()){ |
|
|
|
if (!XCreatorUtils.createXCreator(widget).canEnterIntoParaPane()) { |
|
|
|
//预定义控件工具栏这儿不显示工具栏中没有的预定义控件
|
|
|
|
//预定义控件工具栏这儿不显示工具栏中没有的预定义控件
|
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
predifinedwidgeList.add(new UserDefinedWidgetOption(name)); |
|
|
|
predifinedwidgeList.add(new UserDefinedWidgetOption(name)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean isButtonWidget(String widgetClassName) { |
|
|
|
private boolean isButtonWidget(String widgetClassName) { |
|
|
|
return widgetClassName.endsWith("DeleteRowButton") || widgetClassName.endsWith("AppendRowButton") || widgetClassName.endsWith("TreeNodeToogleButton"); |
|
|
|
return widgetClassName.endsWith("DeleteRowButton") || widgetClassName.endsWith("AppendRowButton") || widgetClassName.endsWith("TreeNodeToogleButton"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setTarget(FormDesigner designer) { |
|
|
|
private void setTarget(FormDesigner designer) { |
|
|
|
if (designer == null) { |
|
|
|
if (designer == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
initFormParaComponent(); |
|
|
|
initFormParaComponent(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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) { |
|
|
|
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 = commonChartNum * (widgetButtonWidth + smallGAP); |
|
|
|
int y = (int)Math.ceil(chartOptions.length/((double)commonChartNum)) * (widgetButtonHeight + smallGAP); |
|
|
|
int y = (int) Math.ceil(chartOptions.length / ((double) commonChartNum)) * (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 +238,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 +267,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 +334,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)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -347,8 +347,9 @@ public class FormParaWidgetPane extends JPanel{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 响应界面改变事件 |
|
|
|
* 响应界面改变事件 |
|
|
|
* @param evt 事件 |
|
|
|
* |
|
|
|
|
|
|
|
* @param evt 事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void fireCreatorModified(DesignerEvent evt) { |
|
|
|
public void fireCreatorModified(DesignerEvent evt) { |
|
|
|
button.setEnabled(designer.getParaComponent() == null); |
|
|
|
button.setEnabled(designer.getParaComponent() == null); |
|
|
@ -356,14 +357,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,17 +376,14 @@ 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)) { |
|
|
|
PopUpWindow.this.setVisible(false); |
|
|
|
if (!OperatingSystem.isMacOS()) { |
|
|
|
|
|
|
|
PopUpWindow.this.setVisible(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -398,9 +395,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 +406,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 +418,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; |
|
|
|
} |
|
|
|
} |
|
|
|