Browse Source

报表块共享,帮助信息显示,数据集合并到表单。以及内边距的一个bug改一下

master
zack 8 years ago
parent
commit
477854d2af
  1. 4
      designer_base/src/com/fr/design/data/BasicTableDataTreePane.java
  2. 20
      designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java
  3. 2
      designer_base/src/com/fr/design/icon/IconPathConstants.java
  4. BIN
      designer_base/src/com/fr/design/images/control/help_close.png
  5. BIN
      designer_base/src/com/fr/design/images/control/help_open.png
  6. 21
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  7. 1
      designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java
  8. 22
      designer_form/src/com/fr/design/designer/creator/XElementCase.java
  9. 140
      designer_form/src/com/fr/design/mainframe/CoverReportPane.java
  10. 38
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java
  11. 73
      designer_form/src/com/fr/design/mainframe/ElementCaseHelpDialog.java
  12. 338
      designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java

4
designer_base/src/com/fr/design/data/BasicTableDataTreePane.java

@ -3,6 +3,7 @@ package com.fr.design.data;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
@ -423,4 +424,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
this.setSmallIcon(BaseUtils.readIcon(IconPathConstants.TD_CONNECTION_ICON_PATH)); this.setSmallIcon(BaseUtils.readIcon(IconPathConstants.TD_CONNECTION_ICON_PATH));
} }
} }
public void addTableData(TableDataSource tableDataSource){
}
} }

20
designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java

@ -39,6 +39,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
public class TableDataTreePane extends BasicTableDataTreePane { public class TableDataTreePane extends BasicTableDataTreePane {
@ -138,6 +139,7 @@ public class TableDataTreePane extends BasicTableDataTreePane {
populate(new TableDataSourceOP(tc)); populate(new TableDataSourceOP(tc));
this.checkButtonEnabled(); this.checkButtonEnabled();
} }
protected void initbuttonGroup() { protected void initbuttonGroup() {
Icon[] iconArray = {BaseUtils.readIcon("/com/fr/design/images/data/datasource.png"), BaseUtils.readIcon("/com/fr/design/images/data/dock/serverdatabase.png")}; Icon[] iconArray = {BaseUtils.readIcon("/com/fr/design/images/data/datasource.png"), BaseUtils.readIcon("/com/fr/design/images/data/dock/serverdatabase.png")};
final Integer[] modeArray = {TEMPLATE_TABLE_DATA, SERVER_TABLE_DATA}; final Integer[] modeArray = {TEMPLATE_TABLE_DATA, SERVER_TABLE_DATA};
@ -267,4 +269,22 @@ public class TableDataTreePane extends BasicTableDataTreePane {
public TableDataTree getDataTree() { public TableDataTree getDataTree() {
return dataTree; return dataTree;
} }
public void addTableData(TableDataSource tableDataSource) {
DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER);
TableDataSource tds = tc.getBook();
Iterator tdIterator = tableDataSource.getTableDataNameIterator();
while (tdIterator.hasNext()) {
String tdName = (String) tdIterator.next();
TableData td = tableDataSource.getTableData(tdName);
if (tds.getTableData(tdName) != null) {
tds.putTableData(tdName + "-fr-el", td);
} else {
tds.putTableData(tdName, td);
}
}
tc.fireTargetModified();
tc.parameterChanged();
dataTree.refresh();
}
} }

2
designer_base/src/com/fr/design/icon/IconPathConstants.java

@ -1 +1 @@
package com.fr.design.icon; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 6.5.6 * Date: 12-12-18 * Time: 上午9:42 * 用于保存所有图标路径的类 */ public class IconPathConstants { private IconPathConstants() { } public static final String ADD_POPMENU_ICON_PATH = "/com/fr/design/images/control/addPopup.png"; public static final String DS_ICON_PATH = "/com/fr/design/images/data/datasource.png"; public static final String CLASS_TD_ICON_PATH = "/com/fr/design/images/data/source/classTableData.png"; public static final String EMB_TD_ICON_PATH = "/com/fr/design/images/data/dataTable.png"; public static final String DS_RELATION_TD_ICON_PATH = "/com/fr/design/images/data/multi.png"; public static final String FILE_TD_ICON_PATH = "/com/fr/design/images/data/file.png"; public static final String DS_TREE_TD_ICON_PATH = "/com/fr/design/images/data/tree.png"; public static final String DS_QUERY_ICON_PATH = "/com/fr/design/images/data/database.png"; public static final String PREVIEW_ICON_PATH = "/com/fr/design/images/m_file/preview.png"; public static final String TD_EDIT_ICON_PATH = "/com/fr/design/images/control/edit.png"; public static final String TD_REMOVE_ICON_PATH = "/com/fr/base/images/cell/control/remove.png"; public static final String TD_CONNECTION_ICON_PATH = "/com/fr/design/images/m_web/connection.png"; public static final String SP_SHOW_ICON_PATH = "/com/fr/design/images/data/store_procedure.png"; public static final String STD_SHOW_ICON_PATH = "/com/fr/design/images/data/dock/serverdatabase.png"; public static final String XMLA_ICON_PATH = "/com/fr/design/images/data/cube.png"; public static final String FORBID_ICON_PATH ="/com/fr/web/images/form/forbid.png"; } package com.fr.design.icon; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 6.5.6 * Date: 12-12-18 * Time: 上午9:42 * 用于保存所有图标路径的类 */ public class IconPathConstants { private IconPathConstants() { } public static final String ADD_POPMENU_ICON_PATH = "/com/fr/design/images/control/addPopup.png"; public static final String DS_ICON_PATH = "/com/fr/design/images/data/datasource.png"; public static final String CLASS_TD_ICON_PATH = "/com/fr/design/images/data/source/classTableData.png"; public static final String EMB_TD_ICON_PATH = "/com/fr/design/images/data/dataTable.png"; public static final String DS_RELATION_TD_ICON_PATH = "/com/fr/design/images/data/multi.png"; public static final String FILE_TD_ICON_PATH = "/com/fr/design/images/data/file.png"; public static final String DS_TREE_TD_ICON_PATH = "/com/fr/design/images/data/tree.png"; public static final String DS_QUERY_ICON_PATH = "/com/fr/design/images/data/database.png"; public static final String PREVIEW_ICON_PATH = "/com/fr/design/images/m_file/preview.png"; public static final String TD_EDIT_ICON_PATH = "/com/fr/design/images/control/edit.png"; public static final String TD_EL_SHARE_HELP_ICON_PATH = "/com/fr/design/images/control/help_open.png"; public static final String TD_EL_SHARE_CLOSE_ICON_PATH = "/com/fr/design/images/control/help_close.png"; public static final String TD_REMOVE_ICON_PATH = "/com/fr/base/images/cell/control/remove.png"; public static final String TD_CONNECTION_ICON_PATH = "/com/fr/design/images/m_web/connection.png"; public static final String SP_SHOW_ICON_PATH = "/com/fr/design/images/data/store_procedure.png"; public static final String STD_SHOW_ICON_PATH = "/com/fr/design/images/data/dock/serverdatabase.png"; public static final String XMLA_ICON_PATH = "/com/fr/design/images/data/cube.png"; public static final String FORBID_ICON_PATH ="/com/fr/web/images/form/forbid.png"; }

BIN
designer_base/src/com/fr/design/images/control/help_close.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

BIN
designer_base/src/com/fr/design/images/control/help_open.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

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

@ -12,6 +12,10 @@ import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.*; import com.fr.design.mainframe.*;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.share.ShareLoader;
import com.fr.form.ui.AbstractFormSharableEditor;
import com.fr.form.ui.ElCaseBindInfo;
import com.fr.form.ui.FormSharableEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -590,4 +594,21 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
* @param msg 帮助信息 * @param msg 帮助信息
*/ */
public void setSharedMsg(String msg){} public void setSharedMsg(String msg){}
/**
* 根据widget设置Xcreator共享信息
* @param widget
*/
public void setShareMsgByWidget(Widget widget){
if (widget != null && (widget instanceof FormSharableEditor)) {
String shareId = ((AbstractFormSharableEditor) widget).getShareId();
ElCaseBindInfo info = ShareLoader.getLoader().getElCaseBindInfoById(shareId);
if (info != null) {
setSharedMsg(info.getGuideInfo());
}
}
}
} }

1
designer_form/src/com/fr/design/designer/creator/XCreatorUtils.java

@ -157,6 +157,7 @@ public class XCreatorUtils {
FRContext.getLogger().error("Error to create xcreator!"); FRContext.getLogger().error("Error to create xcreator!");
creator = new NullCreator(widget, d); creator = new NullCreator(widget, d);
} }
creator.setShareMsgByWidget(widget);//设置共享信息
return creator; return creator;
} }

22
designer_form/src/com/fr/design/designer/creator/XElementCase.java

@ -35,7 +35,7 @@ import java.beans.PropertyDescriptor;
public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider{ public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider{
private UILabel imageLable; private UILabel imageLable;
private JPanel coverPanel; private CoverReportPane coverPanel;
private FormDesigner designer; private FormDesigner designer;
//缩略图 //缩略图
private BufferedImage thumbnailImage; private BufferedImage thumbnailImage;
@ -181,11 +181,10 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
* @param display 是否 * @param display 是否
*/ */
public void displayCoverPane(boolean display){ public void displayCoverPane(boolean display){
coverPanel.setVisible(display); coverPanel.setVisible(display);
coverPanel.setPreferredSize(editor.getPreferredSize()); coverPanel.setBounds(1, 1, (int) editor.getBounds().getWidth(), (int) editor.getBounds().getHeight());
coverPanel.setBounds(editor.getBounds()); editor.repaint();
editor.repaint(); }
}
public JComponent getCoverPane(){ public JComponent getCoverPane(){
return coverPanel; return coverPanel;
@ -263,7 +262,11 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
*/ */
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
super.respondClick(editingMouseListener, e); super.respondClick(editingMouseListener, e);
switchTab(e,editingMouseListener); if (this.isHelpBtnOnFocus()) {
coverPanel.setMsgDisplay(e);
}else {
switchTab(e,editingMouseListener);
}
} }
@ -280,4 +283,9 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[]{ new ElementCasePropertyUI(this)}; return new WidgetPropertyUIProvider[]{ new ElementCasePropertyUI(this)};
} }
@Override
public void setSharedMsg(String msg) {
coverPanel.setHelpMsg(msg);
}
} }

140
designer_form/src/com/fr/design/mainframe/CoverReportPane.java

@ -1,12 +1,19 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
import com.fr.form.share.ShareConstants;
import com.fr.general.FRScreen;
import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.MouseEvent;
/** /**
* Created with IntelliJ IDEA. * Created with IntelliJ IDEA.
@ -14,59 +21,122 @@ import java.awt.*;
* Date: 14-7-24 * Date: 14-7-24
* Time: 上午9:09 * Time: 上午9:09
*/ */
public class CoverReportPane extends JPanel{ public class CoverReportPane extends JPanel {
private UIButton editButton; private UIButton editButton;
private Icon controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_CLOSE_ICON_PATH);
private JComponent controlButton = new JComponent() {
protected void paintComponent(Graphics g) {
g.setColor(UIConstants.NORMAL_BACKGROUND);
g.fillArc(0, 0, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW,
0, 360);
controlMode.paintIcon(this, g, 0, 0);
}
};
private String helpMsg;//帮助信息(后续帮助信息可能会变成标配,就直接放这边了)
private ElementCaseHelpDialog helpDialog = null;
private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F); private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F);
public CoverReportPane(){ public CoverReportPane() {
setLayout(coverLayout); this(StringUtils.EMPTY);
}
public CoverReportPane(String helpMsg) {
this.helpMsg = helpMsg;
setLayout(getCoverLayout());
setBackground(null); setBackground(null);
setOpaque(false); setOpaque(false);
editButton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon(IconPathConstants.TD_EDIT_ICON_PATH)){ editButton = new UIButton(Inter.getLocText("Edit"), IOUtils.readIcon(IconPathConstants.TD_EDIT_ICON_PATH)) {
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return new Dimension(60,24); return new Dimension(60, 24);
} }
}; };
editButton.setBorderPainted(false); editButton.setBorderPainted(false);
editButton.setExtraPainted(false); editButton.setExtraPainted(false);
editButton.setBackground(new Color(176,196,222)); editButton.setBackground(new Color(176, 196, 222));
add(editButton); add(editButton);
add(controlButton);
WidgetPropertyPane.getInstance().getEditingFormDesigner().addDesignerEditListener(new DesignerEditListener() {
@Override
public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == (DesignerEvent.CREATOR_DELETED)
|| evt.getCreatorEventID() == (DesignerEvent.CREATOR_RESIZED)) {
destroyHelpDialog();
}
}
});
}
public String getHelpMsg() {
return helpMsg;
} }
private LayoutManager coverLayout = new LayoutManager() { public void setHelpMsg(String helpMsg) {
this.helpMsg = helpMsg;
}
@Override public void setMsgDisplay(MouseEvent e) {
public void removeLayoutComponent(Component comp) { if (helpDialog == null) {
controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_CLOSE_ICON_PATH);
controlButton.repaint();
helpDialog = new ElementCaseHelpDialog(DesignerContext.getDesignerFrame(), helpMsg);
double screenValue = FRScreen.getByDimension(Toolkit.getDefaultToolkit().getScreenSize()).getValue();
int offsetX = 0;
if (screenValue < FormArea.DEFAULT_SLIDER) {
offsetX = (int) ((1 - screenValue / FormArea.DEFAULT_SLIDER)
* WidgetPropertyPane.getInstance().getEditingFormDesigner().getRootComponent().getWidth() / 2);
}
int rX = WestRegionContainerPane.getInstance().getWidth() + e.getX() + offsetX - 227;//弹出框宽度190加上图标的宽度27加上10的偏移
int rY = 165 + e.getY();//165是设计器最上面几个面板的高度
helpDialog.setLocationRelativeTo(DesignerContext.getDesignerFrame(), rX, rY);
helpDialog.showWindow();
} else {
controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH);
controlButton.repaint();
helpDialog.dispose();
helpDialog = null;
} }
}
@Override protected LayoutManager getCoverLayout() {
public Dimension preferredLayoutSize(Container parent) { return new LayoutManager() {
return parent.getPreferredSize();
}
@Override @Override
public Dimension minimumLayoutSize(Container parent) { public void removeLayoutComponent(Component comp) {
return null; }
}
@Override @Override
public void layoutContainer(Container parent) { public Dimension preferredLayoutSize(Container parent) {
int width = parent.getParent().getWidth(); return parent.getPreferredSize();
int height = parent.getParent().getHeight(); }
int preferWidth = editButton.getPreferredSize().width;
int preferHeight = editButton.getPreferredSize().height; @Override
editButton.setBounds((width - preferWidth)/2, (height - preferHeight)/2, preferWidth, preferHeight); public Dimension minimumLayoutSize(Container parent) {
} return null;
}
@Override
public void layoutContainer(Container parent) {
int width = parent.getParent().getWidth();
int height = parent.getParent().getHeight();
int preferWidth = editButton.getPreferredSize().width;
int preferHeight = editButton.getPreferredSize().height;
editButton.setBounds((width - preferWidth) / 2, (height - preferHeight) / 2, preferWidth, preferHeight);
controlButton.setBounds((width - 28), 0, 27, 27);
}
@Override
public void addLayoutComponent(String name, Component comp) {
}
};
}
@Override
public void addLayoutComponent(String name, Component comp) {
}
};
public void paint(Graphics g) { public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
@ -77,4 +147,14 @@ public class CoverReportPane extends JPanel{
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
super.paint(g); super.paint(g);
} }
public void destroyHelpDialog() {
if (helpDialog != null) {
controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH);
controlButton.repaint();
helpDialog.dispose();
helpDialog = null;
}
}
} }

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

@ -1,14 +1,5 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import java.awt.Color;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import javax.swing.*;
import javax.swing.event.MouseInputAdapter;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.beans.location.MoveUtils; import com.fr.design.beans.location.MoveUtils;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
@ -29,6 +20,11 @@ import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.event.MouseInputAdapter;
import java.awt.*;
import java.awt.event.MouseEvent;
/** /**
* 普通模式下的鼠标点击位置处理器 * 普通模式下的鼠标点击位置处理器
*/ */
@ -291,18 +287,28 @@ public class EditingMouseListener extends MouseInputAdapter {
if (component.isReport()) { if (component.isReport()) {
xElementCase = (XElementCase)component; xElementCase = (XElementCase)component;
UIButton button = (UIButton)xElementCase.getCoverPane().getComponent(0); UIButton button = (UIButton)xElementCase.getCoverPane().getComponent(0);
JComponent button1= (JComponent) xElementCase.getCoverPane().getComponent(1);
if(designer.getCursor().getType() ==Cursor.HAND_CURSOR) { if(designer.getCursor().getType() ==Cursor.HAND_CURSOR) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} // component.getParent() 是报表块所在的XWTitleLayout } // component.getParent() 是报表块所在的XWTitleLayout
int minX = button.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue(); int minX = button.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minX1 = button1.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minY = button.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue(); int minY = button.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue();
if(e.getX() + GAP > minX && e.getX() - GAP < minX + button.getWidth()){ int minY1 = button1.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue();
if( e.getY() + GAP > minY && e.getY() - GAP < minY + button.getHeight()){ if (e.getX() + GAP - xElementCase.getInsets().left > minX && e.getX() - GAP - xElementCase.getInsets().left < minX + button.getWidth()) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); if (e.getY() + GAP - xElementCase.getInsets().top > minY && e.getY() - GAP - xElementCase.getInsets().top < minY + button.getHeight()) {
} designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
} }
xElementCase.displayCoverPane(true); }
xElementCase.setHelpBtnOnFocus(false);
if (e.getX() + GAP - xElementCase.getInsets().left > minX1 && e.getX() - GAP - xElementCase.getInsets().left < minX1 + button1.getWidth()) {
if (e.getY() + GAP - xElementCase.getInsets().top > minY1 && e.getY() - GAP - xElementCase.getInsets().top < minY1 + button1.getHeight()) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
xElementCase.setHelpBtnOnFocus(true);
}
}
xElementCase.displayCoverPane(true);
xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT); xElementCase.setDirections(Direction.TOP_BOTTOM_LEFT_RIGHT);
designer.repaint(); designer.repaint();

73
designer_form/src/com/fr/design/mainframe/ElementCaseHelpDialog.java

@ -0,0 +1,73 @@
package com.fr.design.mainframe;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itextarea.UITextArea;
import javax.swing.*;
import java.awt.*;
/**
* @author zack
* @date 2016-10-14
* @since 8.0
*/
public class ElementCaseHelpDialog extends UIDialog {
private static final int OUTER_WIDTH = 190;
private static final int OUTER_HEIGHT = 120;
private String helpMsg;
private UIScrollPane helpArea;
public ElementCaseHelpDialog(Frame parent, String helpMsg) {
super(parent);
this.helpMsg = helpMsg;
setUndecorated(true);
initHelpArea();
JPanel panel = (JPanel) getContentPane();
initComponents(panel);
setSize(new Dimension(OUTER_WIDTH, OUTER_HEIGHT));
}
private void initHelpArea() {
UITextArea textArea = new UITextArea(helpMsg);
textArea.setEditable(false);
textArea.setBorder(null);
helpArea = new UIScrollPane(textArea);
helpArea.setBounds(0, 0, 190, 120);
helpArea.setBorder(null);
}
private void initComponents(JPanel contentPane) {
contentPane.setLayout(new BorderLayout());
add(helpArea, BorderLayout.CENTER);
}
/**
* 打开帮助框
*/
public void showWindow() {
setVisible(true);
this.setResizable(false);
}
/**
*
*/
@Override
public void checkValid() throws Exception {
}
public void setLocationRelativeTo(JFrame c, int x, int y) {
int dx = 0, dy = 0;
Point compLocation = c.getLocationOnScreen();//获取设计器Jframe坐标作为相对位置原点
setLocation(dx + x, dy + y);
dx = compLocation.x;
dy = compLocation.y + c.getRootPane().getY();//加上底层容器的y坐标(其实就是设计器最上方图标栏的高度)
setLocation(dx + x, dy + y);
}
}

338
designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -1,20 +1,8 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import java.awt.Color;
import java.awt.Component;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JWindow;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.DesignModelAdapter;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.HoverPainter;
import com.fr.design.designer.beans.Painter; import com.fr.design.designer.beans.Painter;
@ -25,177 +13,192 @@ import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.form.share.ShareLoader;
import com.fr.form.ui.SharableElementCaseEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import javax.swing.*;
import java.awt.*;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
/** /**
* 添加模式下鼠标事件处理器 * 添加模式下鼠标事件处理器
*/ */
public class FormCreatorDropTarget extends DropTarget { public class FormCreatorDropTarget extends DropTarget {
private FormDesigner designer; private FormDesigner designer;
/** /**
* 当前鼠标的设计组件 * 当前鼠标的设计组件
*/ */
private Component current; private Component current;
/** /**
* 当前添加模式对应的model * 当前添加模式对应的model
*/ */
private AddingModel addingModel; private AddingModel addingModel;
private final static int GAP = 30; private final static int GAP = 30;
private JWindow promptWindow = new JWindow(); private JWindow promptWindow = new JWindow();
private UIButton promptButton = new UIButton("", BaseUtils.readIcon(IconPathConstants.FORBID_ICON_PATH)); private UIButton promptButton = new UIButton("", BaseUtils.readIcon(IconPathConstants.FORBID_ICON_PATH));
public FormCreatorDropTarget(FormDesigner designer) { public FormCreatorDropTarget(FormDesigner designer) {
this.designer = designer; this.designer = designer;
this.addingModel = designer.getAddingModel(); this.addingModel = designer.getAddingModel();
this.promptWindow.add(promptButton); this.promptWindow.add(promptButton);
} }
private void adding(int x, int y) { private void adding(int x, int y) {
// 当前鼠标所在的组件 // 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(x, y); XCreator hoveredComponent = designer.getComponentAt(x, y);
// 获取该组件所在的焦点容器 // 获取该组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
//cardTagLayout里用到 //cardTagLayout里用到
container.stopAddingState(designer); container.stopAddingState(designer);
boolean success = false; boolean success = false;
if (container != null) { if (container != null) {
// 如果是容器,则调用其acceptComponent接受组件 // 如果是容器,则调用其acceptComponent接受组件
AddingModel model = designer.getAddingModel(); AddingModel model = designer.getAddingModel();
boolean chartEnter2Para =!addingModel.getXCreator().canEnterIntoParaPane() && container.acceptType(XWParameterLayout.class); boolean chartEnter2Para = !addingModel.getXCreator().canEnterIntoParaPane() && container.acceptType(XWParameterLayout.class);
boolean formSubmit2Adapt = !addingModel.getXCreator().canEnterIntoAdaptPane() && container.acceptType(XWFitLayout.class); boolean formSubmit2Adapt = !addingModel.getXCreator().canEnterIntoAdaptPane() && container.acceptType(XWFitLayout.class);
if (model != null && !chartEnter2Para && !formSubmit2Adapt) { if (model != null && !chartEnter2Para && !formSubmit2Adapt) {
success = model.add2Container(designer, container, x, y); success = model.add2Container(designer, container, x, y);
} }
cancelPromptWidgetForbidEnter(); cancelPromptWidgetForbidEnter();
} }
if (success) { if (success) {
// 如果添加成功,则触发相应事件 // 如果添加成功,则触发相应事件
XCreator xCreator = container.acceptType(XWParameterLayout.class) ? designer.getParaComponent() : designer.getRootComponent(); XCreator xCreator = container.acceptType(XWParameterLayout.class) ? designer.getParaComponent() : designer.getRootComponent();
//SetSelection时要确保选中的是最顶层的布局 //SetSelection时要确保选中的是最顶层的布局
//tab布局添加的时候是初始化了XWCardLayout,实际上最顶层的布局是XWCardMainBorderLayout //tab布局添加的时候是初始化了XWCardLayout,实际上最顶层的布局是XWCardMainBorderLayout
XCreator addingXCreator = addingModel.getXCreator(); XCreator addingXCreator = addingModel.getXCreator();
Widget widget = (addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData(); if (addingXCreator.isShared()) {
designer.getSelectionModel().setSelectedCreators( SharableElementCaseEditor sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(addingXCreator.getShareId());
FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget})); if (sharableEditor != null) {
designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(sharableEditor.getTableDataSource());
} else { }
Toolkit.getDefaultToolkit().beep(); }
} Widget widget = (addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData();
designer.getSelectionModel().setSelectedCreators(
// 取消提示 FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget}));
designer.setPainter(null); designer.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED);
// 切换添加状态到普通状态 } else {
designer.stopAddingState(); Toolkit.getDefaultToolkit().beep();
} }
private void entering(int x, int y) { // 取消提示
// 将要添加的组件图标移动到鼠标下的位置 designer.setPainter(null);
addingModel.moveTo(x, y); // 切换添加状态到普通状态
designer.repaint(); designer.stopAddingState();
} }
private void exiting() { private void entering(int x, int y) {
// 将要添加的组件图标移动到鼠标下的位置
addingModel.moveTo(x, y);
designer.repaint();
}
private void exiting() {
cancelPromptWidgetForbidEnter(); cancelPromptWidgetForbidEnter();
// 隐藏组件图标 // 隐藏组件图标
addingModel.reset(); addingModel.reset();
designer.setPainter(null); designer.setPainter(null);
designer.repaint(); designer.repaint();
} }
private void hovering(int x, int y) { private void hovering(int x, int y) {
// 当前位置移植鼠标e所在的位置 // 当前位置移植鼠标e所在的位置
addingModel.moveTo(x, y); addingModel.moveTo(x, y);
// 获取e所在的焦点组件 // 获取e所在的焦点组件
XCreator hotspot = designer.getComponentAt(x, y); XCreator hotspot = designer.getComponentAt(x, y);
// 获取焦点组件所在的焦点容器 // 获取焦点组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hotspot); XLayoutContainer container = XCreatorUtils.getHotspotContainer(hotspot);
//提示组件是否可以拖入 //提示组件是否可以拖入
promptUser(x, y, container); promptUser(x, y, container);
if (container != null) { if (container != null) {
HoverPainter painter = null; HoverPainter painter = null;
if (container != current || designer.getPainter() == null) { if (container != current || designer.getPainter() == null) {
// 如果焦点容器不是当前容器 // 如果焦点容器不是当前容器
if (current != null) { if (current != null) {
// 取消前一个焦点容器的提示渲染器 // 取消前一个焦点容器的提示渲染器
designer.setPainter(null); designer.setPainter(null);
} }
//获取painter的时候要考虑布局之间嵌套的问题 //获取painter的时候要考虑布局之间嵌套的问题
XLayoutContainer xLayoutContainer = container.getTopLayout(); XLayoutContainer xLayoutContainer = container.getTopLayout();
if (xLayoutContainer != null && xLayoutContainer.getParent() != null if (xLayoutContainer != null && xLayoutContainer.getParent() != null
&& ((XLayoutContainer)xLayoutContainer.getParent()).acceptType(XWAbsoluteLayout.class)){ && ((XLayoutContainer) xLayoutContainer.getParent()).acceptType(XWAbsoluteLayout.class)) {
if(!xLayoutContainer.isEditable()){ if (!xLayoutContainer.isEditable()) {
xLayoutContainer = (XLayoutContainer)xLayoutContainer.getParent(); xLayoutContainer = (XLayoutContainer) xLayoutContainer.getParent();
} }
} }
painter = AdapterBus.getContainerPainter(designer, painter = AdapterBus.getContainerPainter(designer,
xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class) ? xLayoutContainer : container); xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class) ? xLayoutContainer : container);
// 为界面设计器设置提示渲染提示器 // 为界面设计器设置提示渲染提示器
designer.setPainter(painter); designer.setPainter(painter);
// 将当前容器更新为新的容器 // 将当前容器更新为新的容器
current = container; current = container;
} else { } else {
// 获取当前设计界面的提示渲染器 // 获取当前设计界面的提示渲染器
Painter p = designer.getPainter(); Painter p = designer.getPainter();
if (p instanceof HoverPainter) { if (p instanceof HoverPainter) {
painter = (HoverPainter) p; painter = (HoverPainter) p;
} }
} }
if (painter != null) { if (painter != null) {
// 为提示渲染器设置焦点位置、区域等渲染参数 // 为提示渲染器设置焦点位置、区域等渲染参数
Rectangle rect = ComponentUtils.getRelativeBounds(container); Rectangle rect = ComponentUtils.getRelativeBounds(container);
rect.x -= designer.getArea().getHorizontalValue(); rect.x -= designer.getArea().getHorizontalValue();
rect.y -= designer.getArea().getVerticalValue(); rect.y -= designer.getArea().getVerticalValue();
painter.setRenderingBounds(rect); painter.setRenderingBounds(rect);
painter.setHotspot(new Point(x, y)); painter.setHotspot(new Point(x, y));
painter.setCreator(addingModel.getXCreator()); painter.setCreator(addingModel.getXCreator());
} }
} else { } else {
// 如果鼠标不在任何组件上,则取消提示器 // 如果鼠标不在任何组件上,则取消提示器
designer.setPainter(null); designer.setPainter(null);
current = null; current = null;
} }
designer.repaint(); designer.repaint();
} }
private void promptUser(int x, int y, XLayoutContainer container){ private void promptUser(int x, int y, XLayoutContainer container) {
if (!addingModel.getXCreator().canEnterIntoParaPane() && container.acceptType(XWParameterLayout.class)){ if (!addingModel.getXCreator().canEnterIntoParaPane() && container.acceptType(XWParameterLayout.class)) {
promptButton.setText(Inter.getLocText("FR-Designer_Forbid_Drag_into_Para_Pane")); promptButton.setText(Inter.getLocText("FR-Designer_Forbid_Drag_into_Para_Pane"));
promptWidgetForbidEnter(x ,y ,container); promptWidgetForbidEnter(x, y, container);
} else if (!addingModel.getXCreator().canEnterIntoAdaptPane() && container.acceptType(XWFitLayout.class)){ } else if (!addingModel.getXCreator().canEnterIntoAdaptPane() && container.acceptType(XWFitLayout.class)) {
promptButton.setText(Inter.getLocText("FR-Designer_Forbid_Drag_into_Adapt_Pane")); promptButton.setText(Inter.getLocText("FR-Designer_Forbid_Drag_into_Adapt_Pane"));
promptWidgetForbidEnter(x ,y , container); promptWidgetForbidEnter(x, y, container);
} else { } else {
cancelPromptWidgetForbidEnter(); cancelPromptWidgetForbidEnter();
} }
} }
private void promptWidgetForbidEnter(int x,int y, XLayoutContainer container){ private void promptWidgetForbidEnter(int x, int y, XLayoutContainer container) {
container.setBorder(BorderFactory.createLineBorder(Color.RED, Constants.LINE_MEDIUM)); container.setBorder(BorderFactory.createLineBorder(Color.RED, Constants.LINE_MEDIUM));
int screen_X = (int)designer.getArea().getLocationOnScreen().getX(); int screen_X = (int) designer.getArea().getLocationOnScreen().getX();
int screen_Y = (int)designer.getArea().getLocationOnScreen().getY(); int screen_Y = (int) designer.getArea().getLocationOnScreen().getY();
this.promptWindow.setSize(promptWindow.getPreferredSize()); this.promptWindow.setSize(promptWindow.getPreferredSize());
this.promptWindow.setPreferredSize(promptWindow.getPreferredSize()); this.promptWindow.setPreferredSize(promptWindow.getPreferredSize());
promptWindow.setLocation( screen_X + x + GAP ,screen_Y + y + GAP); promptWindow.setLocation(screen_X + x + GAP, screen_Y + y + GAP);
promptWindow.setVisible(true); promptWindow.setVisible(true);
} }
private void cancelPromptWidgetForbidEnter(){ private void cancelPromptWidgetForbidEnter() {
if (designer.getParaComponent() != null){ if (designer.getParaComponent() != null) {
designer.getParaComponent().setBorder(BorderFactory.createLineBorder(XCreatorConstants.LAYOUT_SEP_COLOR, Constants.LINE_THIN)); designer.getParaComponent().setBorder(BorderFactory.createLineBorder(XCreatorConstants.LAYOUT_SEP_COLOR, Constants.LINE_THIN));
} }
designer.getRootComponent().setBorder(BorderFactory.createLineBorder(XCreatorConstants.LAYOUT_SEP_COLOR, Constants.LINE_THIN)); designer.getRootComponent().setBorder(BorderFactory.createLineBorder(XCreatorConstants.LAYOUT_SEP_COLOR, Constants.LINE_THIN));
@ -204,45 +207,50 @@ public class FormCreatorDropTarget extends DropTarget {
/** /**
* 拖拽进入 * 拖拽进入
* @param dtde 事件 *
* @param dtde 事件
*/ */
public void dragEnter(DropTargetDragEvent dtde) { public void dragEnter(DropTargetDragEvent dtde) {
Point loc = dtde.getLocation(); Point loc = dtde.getLocation();
this.entering(loc.x, loc.y); this.entering(loc.x, loc.y);
} }
/** /**
* 拖拽移动经过 * 拖拽移动经过
* @param dtde 事件 *
* @param dtde 事件
*/ */
public void dragOver(DropTargetDragEvent dtde) { public void dragOver(DropTargetDragEvent dtde) {
Point loc = dtde.getLocation(); Point loc = dtde.getLocation();
hovering(loc.x, loc.y); hovering(loc.x, loc.y);
} }
/** /**
* 拖拽事件 * 拖拽事件
* @param dtde 事件 *
* @param dtde 事件
*/ */
public void dropActionChanged(DropTargetDragEvent dtde) { public void dropActionChanged(DropTargetDragEvent dtde) {
} }
/** /**
* 拖拽离开 * 拖拽离开
* @param dte 事件 *
* @param dte 事件
*/ */
public void dragExit(DropTargetEvent dte) { public void dragExit(DropTargetEvent dte) {
this.exiting(); this.exiting();
} }
/** /**
* 拖拽释放 * 拖拽释放
* @param dtde 事件 *
* @param dtde 事件
*/ */
public void drop(DropTargetDropEvent dtde) { public void drop(DropTargetDropEvent dtde) {
Point loc = dtde.getLocation(); Point loc = dtde.getLocation();
this.adding(loc.x, loc.y); this.adding(loc.x, loc.y);
//针对在表单中拖入一个控件直接ctrl+s无反应 //针对在表单中拖入一个控件直接ctrl+s无反应
designer.requestFocus(); designer.requestFocus();
} }
} }
Loading…
Cancel
Save