eason-skx 8 years ago
parent
commit
16934b3535
  1. 6
      designer/src/com/fr/poly/PolyComponetsBar.java
  2. BIN
      designer_base/src/com/fr/design/images/form/toolbar/ChartF-MultiPie.png
  3. BIN
      designer_base/src/com/fr/design/images/poly/toolbar/Plugin-ChartF_NewMultiPie.png
  4. 2
      designer_base/src/com/fr/design/module/DesignModuleFactory.java
  5. 3
      designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java
  6. 5
      designer_chart/src/com/fr/design/chart/ChartTypePane.java
  7. 15
      designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java
  8. 11
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java
  9. 7
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  10. 101
      designer_form/src/com/fr/design/designer/creator/XChartEditor.java
  11. 8
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  12. 26
      designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java
  13. 8
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  14. 5
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  15. 5
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  16. 91
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  17. 6
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  18. 6
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java
  19. 7
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  20. 138
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java
  21. 8
      designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java

6
designer/src/com/fr/poly/PolyComponetsBar.java

@ -28,6 +28,7 @@ public class PolyComponetsBar extends JToolBar {
private static Color FOLDER_PANE_BACKGROUND = new Color(214, 223, 247);
private BaseChartNameID[] typeName = BaseChartGetter.getStaticAllChartBaseNames();
private SerIcon[] serIcons;
private static final int MAX_BAR_NUM = 15;
public PolyComponetsBar() {
setOrientation(SwingConstants.VERTICAL);
@ -35,10 +36,11 @@ public class PolyComponetsBar extends JToolBar {
setFloatable(false);
setBackground(UIConstants.NORMAL_BACKGROUND);
setLayout(FRGUIPaneFactory.create1ColumnGridLayout());
serIcons = new SerIcon[typeName.length + 1];
int typeLen = typeName.length < MAX_BAR_NUM ? typeName.length : MAX_BAR_NUM;
serIcons = new SerIcon[typeLen + 1];
serIcons[0] = new SerIcon(PolyECBlock.class, Inter.getLocText("Poly-Report_Block"), "Poly-Report_Block");
this.add(serIcons[0]);
for (int i = 0, len = typeName.length; i < len; i++) {
for (int i = 0; i < typeLen; i++) {
BaseChart[] rowChart = BaseChartGetter.getStaticChartTypes(typeName[i].getPlotID());
serIcons[i + 1] = new SerIcon(rowChart[0], Inter.getLocText(typeName[i].getName()), typeName[i].getName());
this.add(serIcons[i + 1]);

BIN
designer_base/src/com/fr/design/images/form/toolbar/ChartF-MultiPie.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

BIN
designer_base/src/com/fr/design/images/poly/toolbar/Plugin-ChartF_NewMultiPie.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

2
designer_base/src/com/fr/design/module/DesignModuleFactory.java

File diff suppressed because one or more lines are too long

3
designer_chart/src/com/fr/design/ChartTypeInterfaceManager.java

@ -52,9 +52,6 @@ public class ChartTypeInterfaceManager extends XMLFileManager implements ExtraCh
private static ChartTypeInterfaceManager classManager = null;
//判断默认图表是否读取
private static boolean isReadDefault = false;
private static LinkedHashMap<String, IndependentChartUIProvider> chartTypeInterfaces = new LinkedHashMap<String, IndependentChartUIProvider>();
public synchronized static ChartTypeInterfaceManager getInstance() {

5
designer_chart/src/com/fr/design/chart/ChartTypePane.java

@ -31,8 +31,9 @@ public class ChartTypePane extends ChartCommonWizardPane {
charts4Icon = new Chart[this.typeName.length][];
for (int i = 0; i < this.typeName.length; i++) {
Chart[] rowCharts = ChartTypeManager.getInstance().getChartTypes(this.typeName[i].getPlotID());
charts4Icon[i] = new Chart[1];
for (int j = 0; j < 1; j++) {
int rowChartsCount = rowCharts.length;
charts4Icon[i] = new Chart[rowChartsCount];
for (int j = 0; j < rowChartsCount; j++) {
try {
charts4Icon[i][j] = (Chart) rowCharts[j].clone();
charts4Icon[i][j].setTitle(null);

15
designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java

@ -5,6 +5,7 @@ import com.fr.chart.chartattr.Bar2DPlot;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.ChartFactory;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chart.web.ChartHyperPoplink;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.chart.gui.ChartComponent;
@ -16,6 +17,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.ChartHyperEditPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import java.awt.*;
@ -43,7 +45,18 @@ public class ChartHyperPoplinkPane extends BasicBeanPane<ChartHyperPoplink> {
this.add(hyperEditPane, BorderLayout.CENTER);
ChartCollection cc = new ChartCollection();
cc.addChart(new Chart(new Bar2DPlot()));
Chart chart = ChartTypeManager.getFirstChart();
if (chart != null){
try {
cc.addChart((Chart)chart.clone());
} catch (CloneNotSupportedException e) {
FRLogger.getLogger().error(e.getMessage(), e);
}
}else {
cc.addChart(new Chart(new Bar2DPlot()));
}
chartComponent = new ChartComponent();
chartComponent.setPreferredSize(new Dimension(220, 170));// 在单元格弹出时 需要调整保证属性表的大小.

11
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java

@ -14,6 +14,7 @@ import com.fr.design.designer.beans.ConstraintsGroupModel;
import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.painters.FRFitLayoutPainter;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.cardlayout.XWCardLayout;
@ -163,7 +164,7 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter {
return false;
}
//如果当前处于边缘地带, 那么就把他贴到父容器上
matchEdge(x, y);
boolean isMatchEdge = matchEdge(x, y);
int componentHeight = comp.getHeight();
int componentWidth = comp.getWidth();
@ -171,7 +172,13 @@ public class FRFitLayoutAdapter extends AbstractLayoutAdapter {
int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY();
//下半部分高度
int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY();
//布局控件要先判断是不是可编辑
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout();
if(topLayout != null && !isMatchEdge && !topLayout.isEditable()){
return false;
}
if (isCrossPointArea(comp, x, y)) {
return canAcceptWhileCrossPoint(comp, x, y);
}

7
designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java

@ -66,6 +66,13 @@ public class SelectionModel {
// 获取e所在的组件
XCreator comp = designer.getComponentAt(e);
//布局组件的顶层布局如不可编辑,要获取其顶层布局
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout();
if(topLayout != null && !topLayout.isEditable()){
comp = topLayout;
}
// 如果父层是scale和title两个专属容器,返回其父层,组件本身是不让被选中的
if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) {
XCreator parentContainer = (XCreator) comp.getParent();

101
designer_form/src/com/fr/design/designer/creator/XChartEditor.java

@ -1,20 +1,22 @@
package com.fr.design.designer.creator;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.beans.IntrospectionException;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.*;
import com.fr.base.BaseUtils;
import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.*;
import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor;
import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer;
import com.fr.design.module.DesignModuleFactory;
@ -41,6 +43,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
//marro:无奈的属性,暂时想不出好办法
private boolean isRefreshing = false;
private boolean isEditing = false;
private JPanel coverPanel;
public XChartEditor(BaseChartEditor editor) {
this(editor, new Dimension(250, 150));
}
@ -142,17 +147,22 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
}
});
final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartWidgetPropertyPane(formDesigner);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (getDesignerEditor().getEditorTarget() != null) {
propertyPane.setSupportCellData(true);
propertyPane.populateChartPropertyPane(getDesignerEditorTarget().update(), formDesigner);
if (isEditing){
final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartPropertyPane();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (getDesignerEditor().getEditorTarget() != null) {
propertyPane.setSupportCellData(true);
propertyPane.populateChartPropertyPane(getDesignerEditorTarget().update(), formDesigner);
}
}
}
});
return (JComponent)propertyPane;
});
return (JComponent)propertyPane;
}
else{
return (JComponent)DesignModuleFactory.getWidgetPropertyPane(formDesigner);
}
}
private MiddleChartComponent getDesignerEditorTarget() {
@ -167,8 +177,8 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
* 渲染Painter
*/
public void paint(Graphics g) {
super.paint(g);
designerEditor.paintEditor(g, this.getSize());
super.paint(g);
}
/**
@ -180,6 +190,27 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
return new Dimension(250, 100);
}
/**
* 响应点击事件
*
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件
*/
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel();
isEditing = e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR;
displayCoverPane(!isEditing);
selectionModel.selectACreatorAtMouseEvent(e);
if (editingMouseListener.stopEditing()) {
if (this != (XCreator)designer.getRootComponent()) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter);
}
}
}
@Override
protected JComponent initEditor() {
if (designerEditor == null) {
@ -198,6 +229,36 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
});
}
}
return null;
if (editor == null) {
setBorder(DEFALUTBORDER);
editor = new JPanel();
editor.setBackground(null);
editor.setLayout(null);
editor.setOpaque(false);
coverPanel = new CoverReportPane();
coverPanel.setPreferredSize(this.getPreferredSize());
coverPanel.setBounds(this.getBounds());
editor.add(coverPanel);
coverPanel.setVisible(false);
}
return editor;
}
/**
* 是否展现覆盖的pane
* @param display 是否
*/
public void displayCoverPane(boolean display){
coverPanel.setVisible(display);
coverPanel.setPreferredSize(editor.getPreferredSize());
coverPanel.setBounds(editor.getBounds());
editor.repaint();
}
public JComponent getCoverPane(){
return coverPanel;
}
}

8
designer_form/src/com/fr/design/designer/creator/XCreator.java

@ -105,6 +105,14 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public void backupParent() {
setBackupParent(XCreatorUtils.getParentXLayoutContainer(this));
}
/**
* 获取当前布局控件的顶层布局框架如tab布局绝对布局
* @return 封装的顶层布局
*/
public XLayoutContainer getTopLayout(){
return null;
}
/**
* 获取当前XCreator的一个封装父容器

26
designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java

@ -41,6 +41,16 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
protected boolean isRefreshing;
protected int default_Length = 5; // 取指定点坐在的组件,默认为5保证取四侧相邻的组件时x、y在组件内非边框上
/**
* 布局是否可编辑不可则显示编辑层
*/
protected boolean editable = false;
//鼠标移动到布局画出编辑层
protected boolean isMouseEnter = false;
public void setMouseEnter(boolean mouseEnter) {
isMouseEnter = mouseEnter;
}
public XLayoutContainer(WLayout widget, Dimension initSize) {
super(widget, initSize);
this.addContainerListener(this);
@ -446,4 +456,20 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
public void setBackground(Background background){
}
/**
* 布局是否可编辑不可则显示编辑蒙层
* @return 可否编辑
*/
public boolean isEditable(){
return this.editable;
}
/**
* 设置布局是否可编辑不可则显示编辑蒙层
* @param isEditable 可否编辑
*/
public void setEditable(boolean isEditable){
this.editable = isEditable;
}
}

8
designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java

@ -12,6 +12,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XButton;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormHierarchyTreePane;
@ -149,6 +150,8 @@ public class XCardAddButton extends XButton{
XCardSwitchButton showButton = new XCardSwitchButton(titleButton,dimension,cardLayout,tagLayout);
titleButton.setCustomStyle(true);
titleButton.setShowButton(true);
showButton.setBackupParent(tagLayout);
this.tagLayout.setCurrentCard(titleButton);
this.tagLayout.setTabFitIndex(index);
@ -180,4 +183,9 @@ public class XCardAddButton extends XButton{
}
return newTextName;
}
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
}

5
designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java

@ -292,5 +292,10 @@ public class XCardSwitchButton extends XButton {
FormHierarchyTreePane.getInstance().refreshRoot();
selectionModel.setSelectedCreator(designer.getRootComponent());
}
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
}

5
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -367,4 +367,9 @@ public class XWCardLayout extends XLayoutContainer {
mainLayout.setBorder(border);
}
}
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
}

91
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -3,18 +3,24 @@
*/
package com.fr.design.designer.creator.cardlayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
/**
* card布局主体框架
@ -31,6 +37,9 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
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;
/**
* 构造函数
@ -124,7 +133,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
/**
* 重新调整子组件的宽度
* @param 宽度
* @param width 宽度
*/
public void recalculateChildWidth(int width){
ArrayList<?> childrenList = this.getTargetChildrenList();
@ -188,4 +197,72 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
}
}
public void paint(Graphics g) {
super.paint(g);
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (isMouseEnter && !editable) {
int x = 0;
int y = 0;
int w = getWidth();
int h = getHeight();
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F));
g2d.setColor(Color.WHITE);
g2d.fillRect(x, y, w, h);
//画编辑按钮所在框
g2d.setComposite(oldComposite);
g2d.setColor(new Color(176, 196, 222));
g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT);
//画编辑按钮图标
BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH);
g2d.drawImage(
image,
(x + w / 2 - 23),
(y + h / 2 - image.getHeight() / 2),
image.getWidth(),
image.getHeight(),
null,
this
);
g2d.setColor(Color.BLACK);
//画编辑文字
g2d.drawString(Inter.getLocText("Edit"), x + w / 2 - 2, y + h / 2 + 5);
}
}
/**
* 响应点击事件
*
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件
*/
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;
setEditable(isEditing);
selectionModel.selectACreatorAtMouseEvent(e);
designer.repaint();
if (editingMouseListener.stopEditing()) {
if (this != designer.getRootComponent()) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter);
}
}
}
/**
* XWCardMainBorderLayout是card布局主体框架tab的顶层布局
* @return
*/
@Override
public XLayoutContainer getTopLayout() {
return this;
}
}

6
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java

@ -13,6 +13,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWHorizontalBoxLayout;
import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.mainframe.EditingMouseListener;
@ -214,4 +215,9 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
}
}
}
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
}

6
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java

@ -12,6 +12,7 @@ import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWidgetCreator;
import com.fr.design.mainframe.EditingMouseListener;
@ -146,4 +147,9 @@ public class XWCardTitleLayout extends XWBorderLayout {
}
}
}
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
}

7
designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

@ -188,7 +188,7 @@ public class XWTabFitLayout extends XWFitLayout {
/**
* 该布局需要隐藏无需对边框进行操作
* @param 边框
* @param border 边框
*
*/
public void setBorder(Border border) {
@ -362,4 +362,9 @@ public class XWTabFitLayout extends XWFitLayout {
this.hasCalGap = true;
}
@Override
public XLayoutContainer getTopLayout() {
return this.getBackupParent().getTopLayout();
}
}

138
designer_form/src/com/fr/design/mainframe/EditingMouseListener.java

@ -18,12 +18,7 @@ import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.beans.location.Location;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.beans.models.StateModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XEditorHolder;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.*;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.xpane.ToolTipEditor;
@ -45,6 +40,10 @@ public class EditingMouseListener extends MouseInputAdapter {
* 普通模式下对应的model
*/
private StateModel stateModel;
private XLayoutContainer xTopLayoutContainer;
private XLayoutContainer clickTopLayout;
/**
* 获取表单设计器
@ -84,10 +83,14 @@ public class EditingMouseListener extends MouseInputAdapter {
private int minDragSize = 5;
private int minMoveSize = 8;
private static final int EDIT_BTN_WIDTH = 60;
private static final int EDIT_BTN_HEIGHT = 24;
//报表块的编辑按钮不灵敏,范围扩大一点
private static final int GAP = 10;
private XElementCase xElementCase;
private XChartEditor xChartEditor;
private JWindow promptWindow = new JWindow();
@ -244,6 +247,12 @@ public class EditingMouseListener extends MouseInputAdapter {
*/
public void mouseMoved(MouseEvent e) {
XCreator component = designer.getComponentAt(e);
setCoverPaneNotDisplay();
if(processTopLayoutMouseMove(component, e)){
return;
}
if (component instanceof XEditorHolder) {
XEditorHolder xcreator = (XEditorHolder) component;
Rectangle rect = xcreator.getBounds();
@ -267,17 +276,15 @@ public class EditingMouseListener extends MouseInputAdapter {
if (!BaseUtils.isAuthorityEditing()) {
stateModel.setDirection(dir);
}
if(xElementCase != null){
xElementCase.displayCoverPane(false);
}
if (component.isReport()) {
xElementCase = (XElementCase)component;
UIButton button = (UIButton)xElementCase.getCoverPane().getComponent(0);
if(designer.getCursor().getType() ==Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} // component.getParent() 是报表块所在的XWTitleLayout
int minX = button.getX() + component.getX() + component.getParent().getX() - designer.getArea().getHorizontalValue();
int minY = button.getY() + component.getY() + component.getParent().getY() + designer.getParaHeight() - designer.getArea().getVerticalValue();
int minX = button.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minY = button.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue();
if(e.getX() + GAP > minX && e.getX() - GAP < minX + button.getWidth()){
if( e.getY() + GAP > minY && e.getY() - GAP < minY + button.getHeight()){
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
@ -285,16 +292,84 @@ public class EditingMouseListener extends MouseInputAdapter {
}
xElementCase.displayCoverPane(true);
xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT);
designer.repaint();
} else {
if(xElementCase != null){
xElementCase.displayCoverPane(false);
designer.repaint();
}
return;
}
processChartEditorMouseMove(component, e);
designer.repaint();
}
/**
private void setCoverPaneNotDisplay(){
if (xElementCase != null){
xElementCase.displayCoverPane(false);
}
if (xChartEditor != null){
xChartEditor.displayCoverPane(false);
}
if (xTopLayoutContainer != null) {
xTopLayoutContainer.setMouseEnter(false);
}
designer.repaint();
}
private boolean processTopLayoutMouseMove(XCreator component, MouseEvent e){
XLayoutContainer parent = XCreatorUtils.getHotspotContainer(component).getTopLayout();
if (parent != null){
xTopLayoutContainer = parent;
xTopLayoutContainer.setMouseEnter(true);
designer.repaint();
if(!xTopLayoutContainer.isEditable()) {
if (designer.getCursor().getType() == Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
if (e.getX() > (parent.getX() + parent.getWidth() / 2 - EDIT_BTN_WIDTH / 2 - GAP)
&& e.getX() < (parent.getX() + parent.getWidth() / 2 + EDIT_BTN_WIDTH / 2 + GAP)) {
if (e.getY() > (parent.getY() + parent.getHeight() / 2 - EDIT_BTN_HEIGHT / 2 - GAP)
&& e.getY() < (parent.getY() + parent.getHeight() / 2 + EDIT_BTN_HEIGHT / 2 + GAP + designer.getParaHeight())) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
}
return true;
}
}
return false;
}
private void processChartEditorMouseMove(XCreator component, MouseEvent e){
if (component instanceof XChartEditor) {
xChartEditor = (XChartEditor)component;
UIButton button = (UIButton)xChartEditor.getCoverPane().getComponent(0);
if(designer.getCursor().getType() ==Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
int minX = button.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minY = button.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue();
if(e.getX() + GAP > minX && e.getX() - GAP < minX + button.getWidth()){
if( e.getY() + GAP > minY && e.getY() - GAP < minY + button.getHeight()){
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
}
xChartEditor.displayCoverPane(true);
xChartEditor.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT);
designer.repaint();
}
}
private int getParentPositionX(XCreator comp, int x){
return comp.getParent() == null ?
x : getParentPositionX((XCreator)comp.getParent(), comp.getParent().getX() + x);
}
private int getParentPositionY(XCreator comp, int y) {
return comp.getParent() == null ?
y : getParentPositionY((XCreator) comp.getParent(), comp.getParent().getY() + y);
}
/**
* 拖拽
* @param e 鼠标事件
*/
@ -342,6 +417,25 @@ public class EditingMouseListener extends MouseInputAdapter {
designer.repaint();
}
private XCreator processTopLayoutMouseClick(XCreator creator){
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(creator).getTopLayout();
if(topLayout != null){
if (clickTopLayout != null && clickTopLayout != topLayout){
clickTopLayout.setEditable(false);
}
clickTopLayout = topLayout;
if(!topLayout.isEditable()) {
creator = topLayout;
}
}
else{
if(clickTopLayout != null){
clickTopLayout.setEditable(false);
}
}
return creator;
}
/**
* 点击
* @param e 鼠标事件
@ -351,6 +445,9 @@ public class EditingMouseListener extends MouseInputAdapter {
return;
}
XCreator creator = designer.getComponentAt(e);
creator = processTopLayoutMouseClick(creator);
if(creator != null){
creator.respondClick(this, e);
}
@ -368,10 +465,9 @@ public class EditingMouseListener extends MouseInputAdapter {
if (designer.getCursor().getType() != Cursor.DEFAULT_CURSOR) {
designer.setCursor(Cursor.getDefaultCursor());
}
if (xElementCase != null){
xElementCase.displayCoverPane(false);
designer.repaint();
}
setCoverPaneNotDisplay();
cancelPromptWidgetForbidEnter();
}

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

@ -46,7 +46,7 @@ public class FormParaWidgetPane extends JPanel{
//预定义控件最多显示20行
private int preWidgetShowMaxRow = 20;
//显示8个图表组件
private int commonChartNum = 8;
private static final int commonChartNum = 8;
//显示10个普通控件
private int commonWidgetNum = 10;
private JSeparator jSeparatorPara;
@ -118,7 +118,6 @@ public class FormParaWidgetPane extends JPanel{
// 初始化的时候根据图表的总个数获得单行显示图表的个数
int totalChartNums = loadChartOptions().length;
if (totalChartNums > 0) {
commonChartNum = ++totalChartNums/2;
JPanel chartTypePane = new JPanel(new FlowLayout());
for (int i = 0;i < commonChartNum ;i++) {
chartTypePane.add( new ToolBarButton(loadChartOptions()[i]));
@ -209,11 +208,12 @@ public class FormParaWidgetPane extends JPanel{
public void mouseClicked(MouseEvent e) {
if(chartTypeWindow == null) {
JPanel componentsPara = new JPanel(new FlowLayout(FlowLayout.LEFT));
for (WidgetOption chartOption : loadChartOptions()) {
WidgetOption[] chartOptions = loadChartOptions();
for (WidgetOption chartOption : chartOptions) {
componentsPara.add( new ToolBarButton(chartOption));
}
int x = commonChartNum * (widgetButtonWidth + smallGAP);
int y = (int)Math.ceil(((double)loadWidgetOptions().length/(double)commonChartNum)) * (widgetButtonHeight + smallGAP);
int y = (int)Math.ceil(chartOptions.length/((double)commonChartNum)) * (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());

Loading…
Cancel
Save