Browse Source

Merge pull request #687 in BA/design from ~ZHOUPING/design:dev to dev

* commit '5dcbc23681651c49f56e22284c097f82b61c29d8':
  REPORT-1814 表单tab块的改良bug pmd
  REPORT-1814 表单tab块的改良bug tab交互改良,页签可以移动
master
superman 8 years ago
parent
commit
02179b3aa3
  1. 6
      designer_base/src/com/fr/design/locale/designer.properties
  2. 4
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  3. 4
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  4. 6
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  5. 4
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  6. 4
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  7. 32
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveCustomAction.java
  8. 66
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java
  9. 65
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java
  10. 64
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java
  11. 64
      designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java
  12. 8
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  13. 78
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  14. 14
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  15. 14
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  16. 129
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java

6
designer_base/src/com/fr/design/locale/designer.properties

@ -538,4 +538,8 @@ FR-Designer_Allow_Blank=Allow Blank
FR-Designer_PageSetup_Page=Page
FR-Designer_Custom_Job_Description=Description
FR-Designer_Property=Property
FR-Designer_ClassName=Class Name
FR-Designer_ClassName=Class Name
FR-Designer-Move_Tab_First=move to first
FR-Designer-Move_Tab_End=move to end
FR-Designer-Move_Tab_Next=move to next
FR-Designer-Move_Tab_Prev=move to previous

4
designer_base/src/com/fr/design/locale/designer_en_US.properties

@ -539,3 +539,7 @@ FR-Designer_PageSetup_Page=Page
FR-Designer_Custom_Job_Description=Description
FR-Designer_Property=Property
FR-Designer_ClassName=Class Name
FR-Designer-Move_Tab_First=move to first
FR-Designer-Move_Tab_End=move to end
FR-Designer-Move_Tab_Next=move to next
FR-Designer-Move_Tab_Prev=move to previous

4
designer_base/src/com/fr/design/locale/designer_ja_JP.properties

@ -518,3 +518,7 @@ FR-Designer_PageSetup_Page=\u30DA\u30FC\u30B8
FR-Designer_Custom_Job_Description=\u8A18\u8FF0
FR-Designer_Property=\u5C5E\u6027
FR-Designer_ClassName=\u985E\u540D
FR-Designer-Move_Tab_First=
FR-Designer-Move_Tab_End=
FR-Designer-Move_Tab_Next=
FR-Designer-Move_Tab_Prev=

6
designer_base/src/com/fr/design/locale/designer_ko_KR.properties

@ -512,4 +512,8 @@ FR-Designer_Allow_Blank=\uBE48\uCE78\uD5C8\uC6A9
FR-Designer_PageSetup_Page=\uC6F9\uD398\uC774\uC9C0
FR-Designer_Custom_Job_Description=\uC124\uBA85
FR-Designer_Property=\uC18D\uC131
FR-Designer_ClassName=\uD074\uB798\uC2A4\uB124\uC784
FR-Designer_ClassName=\uD074\uB798\uC2A4\uB124\uC784
FR-Designer-Move_Tab_First=
FR-Designer-Move_Tab_End=
FR-Designer-Move_Tab_Next=
FR-Designer-Move_Tab_Prev=

4
designer_base/src/com/fr/design/locale/designer_zh_CN.properties

@ -543,4 +543,8 @@ FR-Designer_PageSetup_Page=\u9875\u9762
FR-Designer_Custom_Job_Description=\u63CF\u8FF0
FR-Designer_Property=\u5C5E\u6027
FR-Designer_ClassName=\u7C7B\u540D
FR-Designer-Move_Tab_First=\u79FB\u52A8\u5230\u9996\u4F4D
FR-Designer-Move_Tab_End=\u79FB\u52A8\u5230\u672B\u5C3E
FR-Designer-Move_Tab_Next=\u5F80\u540E\u79FB\u52A8
FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52A8

4
designer_base/src/com/fr/design/locale/designer_zh_TW.properties

@ -531,3 +531,7 @@ FR-Designer_PageSetup_Page=\u9801\u9762
FR-Designer_Custom_Job_Description=\u63CF\u8FF0
FR-Designer_Property=\u5C6C\u6027
FR-Designer_ClassName=\u985E\u540D
FR-Designer-Move_Tab_First=\u79FB\u52D5\u5230\u9996\u4F4D
FR-Designer-Move_Tab_End=\u79FB\u52D5\u5230\u672B\u5C3E
FR-Designer-Move_Tab_Next=\u5F80\u5F8C\u79FB\u52D5
FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52D5

32
designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveCustomAction.java

@ -0,0 +1,32 @@
package com.fr.design.designer.creator.cardlayout;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.actions.FormUndoableAction;
import com.fr.design.mainframe.FormDesigner;
/**
* Created by zhouping on 2017/2/9.
*/
public class TabMoveCustomAction extends FormUndoableAction {
private XCardSwitchButton xCardSwitchButton;
public TabMoveCustomAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) {
super(t);
this.setName("");
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
this.xCardSwitchButton = xCardSwitchButton;
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
return false;
}
public XCardSwitchButton getxCardSwitchButton() {
return xCardSwitchButton;
}
public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) {
this.xCardSwitchButton = xCardSwitchButton;
}
}

66
designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveEndAction.java

@ -0,0 +1,66 @@
package com.fr.design.designer.creator.cardlayout;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.actions.FormUndoableAction;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
/**
* Created by zhouping on 2017/2/9.
*/
public class TabMoveEndAction extends FormUndoableAction {
private XCardSwitchButton xCardSwitchButton;
public TabMoveEndAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) {
super(t);
this.setName(Inter.getLocText("FR-Designer-Move_Tab_End"));
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/rightright.png"));
this.xCardSwitchButton = xCardSwitchButton;
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
XWCardTagLayout xwCardTagLayout = xCardSwitchButton.getTagLayout();
XWCardLayout xwCardLayout = xCardSwitchButton.getCardLayout();
CardSwitchButton currentButton = (CardSwitchButton) xCardSwitchButton.toData();
try {
int currentIndex = currentButton.getIndex();
int maxIndex = xwCardTagLayout.getComponentCount();
XWTabFitLayout xCurrentTab = (XWTabFitLayout) xwCardLayout.getXCreator(currentIndex);
WTabFitLayout currentTab = (WTabFitLayout) xCurrentTab.toData();
xwCardTagLayout.setSwitchingTab(true);
//修改当前tab往后所有tab的索引号
for (int i = currentIndex + 1; i < maxIndex; i++) {
CardSwitchButton tempBtn = (CardSwitchButton) xwCardTagLayout.getXCreator(i).toData();
tempBtn.setIndex(i - 1);
WTabFitLayout tempTab = (WTabFitLayout) xwCardLayout.getXCreator(i).toData();
tempTab.setIndex(i - 1);
tempTab.setTabNameIndex(i - 1);
}
xwCardTagLayout.remove(xCardSwitchButton);
xwCardTagLayout.add(xCardSwitchButton);
xwCardLayout.remove(xCurrentTab);
xwCardLayout.add(xCurrentTab);
currentButton.setIndex(maxIndex - 1);
currentTab.setIndex(maxIndex - 1);
currentTab.setTabNameIndex(maxIndex - 1);
xwCardTagLayout.setSwitchingTab(false);
}catch (Exception e){
xwCardTagLayout.setSwitchingTab(false);
FRLogger.getLogger().error(e.getMessage());
return false;
}
return true;
}
public XCardSwitchButton getxCardSwitchButton() {
return xCardSwitchButton;
}
public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) {
this.xCardSwitchButton = xCardSwitchButton;
}
}

65
designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveFirstAction.java

@ -0,0 +1,65 @@
package com.fr.design.designer.creator.cardlayout;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.actions.FormUndoableAction;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
/**
* Created by zhouping on 2017/2/9.
*/
public class TabMoveFirstAction extends FormUndoableAction {
private XCardSwitchButton xCardSwitchButton;
public TabMoveFirstAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) {
super(t);
this.setName(Inter.getLocText("FR-Designer-Move_Tab_First"));
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/leftleft.png"));
this.xCardSwitchButton = xCardSwitchButton;
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
XWCardTagLayout xwCardTagLayout = xCardSwitchButton.getTagLayout();
XWCardLayout xwCardLayout = xCardSwitchButton.getCardLayout();
CardSwitchButton currentButton = (CardSwitchButton) xCardSwitchButton.toData();
try {
int currentIndex = currentButton.getIndex();
XWTabFitLayout xCurrentTab = (XWTabFitLayout) xwCardLayout.getXCreator(currentIndex);
WTabFitLayout currentTab = (WTabFitLayout) xCurrentTab.toData();
xwCardTagLayout.setSwitchingTab(true);
//修改当前tab往前所有tab的索引号
for (int i = currentIndex - 1; i >= 0; i--) {
CardSwitchButton tempBtn = (CardSwitchButton) xwCardTagLayout.getXCreator(i).toData();
tempBtn.setIndex(i + 1);
WTabFitLayout tempTab = (WTabFitLayout) xwCardLayout.getXCreator(i).toData();
tempTab.setIndex(i + 1);
tempTab.setTabNameIndex(i + 1);
}
xwCardTagLayout.remove(xCardSwitchButton);
xwCardTagLayout.add(xCardSwitchButton, 0);
xwCardLayout.remove(xCurrentTab);
xwCardLayout.add(xCurrentTab, 0);
currentButton.setIndex(0);
currentTab.setIndex(0);
currentTab.setTabNameIndex(0);
xwCardTagLayout.setSwitchingTab(false);
}catch (Exception e){
xwCardTagLayout.setSwitchingTab(false);
FRLogger.getLogger().error(e.getMessage());
return false;
}
return true;
}
public XCardSwitchButton getxCardSwitchButton() {
return xCardSwitchButton;
}
public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) {
this.xCardSwitchButton = xCardSwitchButton;
}
}

64
designer_form/src/com/fr/design/designer/creator/cardlayout/TabMoveNextAction.java

@ -0,0 +1,64 @@
package com.fr.design.designer.creator.cardlayout;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.actions.FormUndoableAction;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
/**
* Created by zhouping on 2017/2/9.
*/
public class TabMoveNextAction extends FormUndoableAction {
private XCardSwitchButton xCardSwitchButton;
public TabMoveNextAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) {
super(t);
this.setName(Inter.getLocText("FR-Designer-Move_Tab_Next"));
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/right.png"));
this.xCardSwitchButton = xCardSwitchButton;
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
XWCardTagLayout xwCardTagLayout = xCardSwitchButton.getTagLayout();
XWCardLayout xwCardLayout = xCardSwitchButton.getCardLayout();
CardSwitchButton currentButton = (CardSwitchButton) xCardSwitchButton.toData();
try {
int currentIndex = currentButton.getIndex();
XWTabFitLayout xCurrentTab = (XWTabFitLayout) xwCardLayout.getXCreator(currentIndex);
WTabFitLayout currentTab = (WTabFitLayout) xCurrentTab.toData();
xwCardTagLayout.setSwitchingTab(true);
//修改下一个tab的索引号
CardSwitchButton nextBtn = (CardSwitchButton) xwCardTagLayout.getXCreator(currentIndex + 1).toData();
nextBtn.setIndex(currentIndex);
WTabFitLayout nextTab = (WTabFitLayout) xwCardLayout.getXCreator(currentIndex + 1).toData();
nextTab.setIndex(currentIndex);
nextTab.setTabNameIndex(currentIndex);
xwCardTagLayout.remove(xCardSwitchButton);
xwCardTagLayout.add(xCardSwitchButton, currentIndex + 1);
xwCardLayout.remove(xCurrentTab);
xwCardLayout.add(xCurrentTab, currentIndex + 1);
currentButton.setIndex(currentIndex + 1);
currentTab.setIndex(currentIndex + 1);
currentTab.setTabNameIndex(currentIndex + 1);
xwCardTagLayout.setSwitchingTab(false);
}catch (Exception e){
xwCardTagLayout.setSwitchingTab(false);
FRLogger.getLogger().error(e.getMessage());
return false;
}
return true;
}
public XCardSwitchButton getxCardSwitchButton() {
return xCardSwitchButton;
}
public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) {
this.xCardSwitchButton = xCardSwitchButton;
}
}

64
designer_form/src/com/fr/design/designer/creator/cardlayout/TabMovePrevAction.java

@ -0,0 +1,64 @@
package com.fr.design.designer.creator.cardlayout;
import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.actions.FormUndoableAction;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
/**
* Created by zhouping on 2017/2/9.
*/
public class TabMovePrevAction extends FormUndoableAction {
private XCardSwitchButton xCardSwitchButton;
public TabMovePrevAction(FormDesigner t, XCardSwitchButton xCardSwitchButton) {
super(t);
this.setName(Inter.getLocText("FR-Designer-Move_Tab_Prev"));
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/control/left.png"));
this.xCardSwitchButton = xCardSwitchButton;
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
XWCardTagLayout xwCardTagLayout = xCardSwitchButton.getTagLayout();
XWCardLayout xwCardLayout = xCardSwitchButton.getCardLayout();
CardSwitchButton currentButton = (CardSwitchButton) xCardSwitchButton.toData();
try {
int currentIndex = currentButton.getIndex();
XWTabFitLayout xCurrentTab = (XWTabFitLayout) xwCardLayout.getXCreator(currentIndex);
WTabFitLayout currentTab = (WTabFitLayout) xCurrentTab.toData();
xwCardTagLayout.setSwitchingTab(true);
//修改上一个tab的索引号
CardSwitchButton prevBtn = (CardSwitchButton) xwCardTagLayout.getXCreator(currentIndex - 1).toData();
prevBtn.setIndex(currentIndex);
WTabFitLayout prevTab = (WTabFitLayout) xwCardLayout.getXCreator(currentIndex - 1).toData();
prevTab.setIndex(currentIndex);
prevTab.setTabNameIndex(currentIndex);
xwCardTagLayout.remove(xCardSwitchButton);
xwCardTagLayout.add(xCardSwitchButton, currentIndex - 1);
xwCardLayout.remove(xCurrentTab);
xwCardLayout.add(xCurrentTab, currentIndex - 1);
currentButton.setIndex(currentIndex - 1);
currentTab.setIndex(currentIndex - 1);
currentTab.setTabNameIndex(currentIndex - 1);
xwCardTagLayout.setSwitchingTab(false);
}catch (Exception e){
xwCardTagLayout.setSwitchingTab(false);
FRLogger.getLogger().error(e.getMessage());
return false;
}
return true;
}
public XCardSwitchButton getxCardSwitchButton() {
return xCardSwitchButton;
}
public void setxCardSwitchButton(XCardSwitchButton xCardSwitchButton) {
this.xCardSwitchButton = xCardSwitchButton;
}
}

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

@ -89,12 +89,12 @@ public class XCardAddButton extends XButton{
// addbutton对应的XWCardLayout和XWCardTagLayout暂未存入到xml中,重新打开之后先根据父子层获取
if(cardLayout == null && tagLayout ==null ){
initRalateLayout();
initRelateLayout();
}
int index = cardLayout.toData().getWidgetCount();
//添加新的tab,并将原来的设为未选中状态
setTabUnselectd();
setTabUnselected();
addTab(index);
this.tagLayout.adjustComponentWidth();
@ -110,7 +110,7 @@ public class XCardAddButton extends XButton{
LayoutUtils.layoutRootContainer(designer.getRootComponent());
}
private void initRalateLayout(){
private void initRelateLayout(){
XWCardTitleLayout titleLayout = (XWCardTitleLayout)this.getBackupParent();
this.tagLayout = titleLayout.getTagPart();
@ -129,7 +129,7 @@ public class XCardAddButton extends XButton{
}
//将原来的tab页设置为未选中状态
private void setTabUnselectd(){
private void setTabUnselected(){
for(int i=0;i<this.tagLayout.getComponentCount();i++){
WCardTagLayout layout = (WCardTagLayout) this.tagLayout.toData();
CardSwitchButton button = layout.getSwitchButton(i);

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

@ -3,13 +3,6 @@
*/
package com.fr.design.designer.creator.cardlayout;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
import java.util.*;
import javax.swing.*;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
@ -25,6 +18,7 @@ import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormHierarchyTreePane;
import com.fr.design.mainframe.JForm;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.LayoutBorderStyle;
@ -34,6 +28,13 @@ import com.fr.general.Background;
import com.fr.general.FRFont;
import com.fr.general.Inter;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
import java.util.HashMap;
import java.util.Map;
/**
*
*
@ -42,11 +43,11 @@ import com.fr.general.Inter;
public class XCardSwitchButton extends XButton {
private static final int LEFT_GAP = 16;
private static Icon MOUSE_COLSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png");
private static Icon MOUSE_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png");
//设置的图片类型
private static final String COLORBACKGROUNDTYPE = "ColorBackground";
private static final String DEFAULTTYPE = "default";
private static final String COLOR_BACKGROUND_TYPE = "ColorBackground";
private static final String DEFAULT_TYPE = "default";
private static final String DEFAULT_FONT_NAME = "SimSun";
//默认颜色
@ -75,7 +76,7 @@ public class XCardSwitchButton extends XButton {
private boolean isCustomStyle;
private UILabel label;
private Icon closeIcon = MOUSE_COLSE;
private Icon closeIcon = MOUSE_CLOSE;
public XWCardTagLayout getTagLayout() {
return tagLayout;
@ -144,16 +145,17 @@ public class XCardSwitchButton extends XButton {
//关闭重新打开,相关的layout未存到xml中,初始化
if(cardLayout == null){
initRalateLayout(this);
initRelateLayout(this);
}
//获取当前tab的index
XCardSwitchButton button = this;
CardSwitchButton currentButton = (CardSwitchButton) button.toData();
int index = currentButton.getIndex();
int maxIndex = cardLayout.getComponentCount() - 1;
//点击删除图标时
if (isSeletectedClose(e,designer)) {
if (isSelectedClose(e, designer)) {
//当删除到最后一个tab时,删除整个tab布局
if(tagLayout.getComponentCount() <= MIN_SIZE){
deleteTabLayout(selectionModel, designer);
@ -169,22 +171,44 @@ public class XCardSwitchButton extends XButton {
//将当前tab按钮改为选中状态
changeButtonState(index);
// 切换到当前tab按钮对应的tabFitLayout
XWTabFitLayout tabFitLayout = (XWTabFitLayout) cardLayout.getComponent(index);
XCardSwitchButton xCardSwitchButton = (XCardSwitchButton) this.tagLayout.getComponent(index);
tabFitLayout.setxCardSwitchButton(xCardSwitchButton);
selectionModel.setSelectedCreator(tabFitLayout);
if (editingMouseListener.stopEditing()) {
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer,
this);
editingMouseListener.startEditing(this,
adapter.getDesignerEditor(), adapter);
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this);
editingMouseListener.startEditing(this, adapter.getDesignerEditor(), adapter);
}
setTabsAndAdjust();
if(SwingUtilities.isRightMouseButton(e)){
showPopupMenu(editingMouseListener, e, index, maxIndex);
}
}
private void showPopupMenu(EditingMouseListener editingMouseListener, MouseEvent e, int index, int maxIndex) {
JPopupMenu jPopupMenu = new JPopupMenu();
Action first = new TabMoveFirstAction(editingMouseListener.getDesigner(), this);
Action prev = new TabMovePrevAction(editingMouseListener.getDesigner(), this);
Action next = new TabMoveNextAction(editingMouseListener.getDesigner(), this);
Action end = new TabMoveEndAction(editingMouseListener.getDesigner(), this);
if (index == 0){
first.setEnabled(false);
prev.setEnabled(false);
}
if (index == maxIndex){
next.setEnabled(false);
end.setEnabled(false);
}
jPopupMenu.add(first);
jPopupMenu.add(prev);
jPopupMenu.add(next);
jPopupMenu.add(end);
GUICoreUtils.showPopupMenu(jPopupMenu, editingMouseListener.getDesigner(), e.getX(), e.getY());
}
//删除card,同时修改其他switchbutton和tabfit的index
private void deleteCard(XCardSwitchButton button,int index){
String titleName = button.getContentLabel().getText();
@ -216,7 +240,7 @@ public class XCardSwitchButton extends XButton {
//SwitchButton对应的XWCardLayout和XWCardTagLayout暂未存到xml中,重新打开时根据父子层关系获取
private void initRalateLayout(XCardSwitchButton button){
private void initRelateLayout(XCardSwitchButton button){
this.tagLayout = (XWCardTagLayout)this.getBackupParent();
XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.tagLayout.getBackupParent();
XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent();
@ -224,7 +248,7 @@ public class XCardSwitchButton extends XButton {
}
//是否进入点击关闭按钮区域
private boolean isSeletectedClose(MouseEvent e,FormDesigner designer){
private boolean isSelectedClose(MouseEvent e, FormDesigner designer){
int diff = designer.getArea().getHorScrollBar().getValue();
@ -276,7 +300,7 @@ public class XCardSwitchButton extends XButton {
super.paintComponent(g);
setTabsAndAdjust();
Graphics2D g2d = (Graphics2D) g;
drawBackgorund();
drawBackground();
drawTitle();
Dimension panelSize = this.getContentLabel().getSize();
this.getContentBackground().paint(g, new Rectangle2D.Double(0, 0, panelSize.getWidth(), panelSize.getHeight()));
@ -289,13 +313,13 @@ public class XCardSwitchButton extends XButton {
}
//画背景
private void drawBackgorund(){
private void drawBackground(){
CardSwitchButton button = (CardSwitchButton)this.toData();
Background currentBackground;
currentBackground = this.getSelectBackground();
//这边就是button的背景图片,图片的是image,默认的是color,所以不应该是针对null的判断
String type = currentBackground != null? currentBackground.getBackgroundType() : DEFAULTTYPE;
if (type.equals(COLORBACKGROUNDTYPE) || type.equals(DEFAULTTYPE)) {
String type = currentBackground != null? currentBackground.getBackgroundType() : DEFAULT_TYPE;
if (type.equals(COLOR_BACKGROUND_TYPE) || type.equals(DEFAULT_TYPE)) {
ColorBackground background;
if(button.isShowButton()){
this.rebuid();
@ -314,7 +338,7 @@ public class XCardSwitchButton extends XButton {
CardSwitchButton button = (CardSwitchButton) this.toData();
this.setButtonText(button.getText());
if (this.cardLayout == null) {
initRalateLayout(this);
initRelateLayout(this);
}
LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle();

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

@ -255,7 +255,12 @@ public class XWCardLayout extends XLayoutContainer {
creator.setDirections(null);
WCardLayout layout = this.toData();
Widget w = creator.toData();
layout.addWidget(w);
for (int i = 0, count = this.getComponentCount(); i < count; i++) {
if (creator == this.getComponent(i)) {
layout.addWidget(w, i);
}
}
}
@Override
@ -339,7 +344,7 @@ public class XWCardLayout extends XLayoutContainer {
@Override
public void propertyChange(){
WCardLayout cardLayout = toData();
changeRalateSwitchCardname(cardLayout.getWidgetName());
changeRelateSwitchCardName(cardLayout.getWidgetName());
}
}),
new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass(
@ -389,8 +394,8 @@ public class XWCardLayout extends XLayoutContainer {
}
}
//修改相关SwtchButton所绑定的cardLayout控件名
private void changeRalateSwitchCardname(String cardLayoutName) {
//修改相关SwitchButton所绑定的cardLayout控件名
private void changeRelateSwitchCardName(String cardLayoutName) {
XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout) this.getBackupParent();
WCardMainBorderLayout border = borderLayout.toData();
WCardTitleLayout titleLayout = border.getTitlePart();
@ -413,7 +418,6 @@ public class XWCardLayout extends XLayoutContainer {
SelectionModel selectionModel = designer.getSelectionModel();
selectionModel.setSelectedCreator(mainLayout);
selectionModel.deleteSelection();
return;
}
@Override
public void setBorder(Border border) {

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

@ -34,6 +34,8 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
private static final int MIN_SIZE = 1;
private String tagName = "Tab";
private boolean switchingTab = false;
//增加一个tabNameIndex防止tabFitLayout重名
private int tabFitIndex = 0;
@ -63,6 +65,14 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
this.tagName = tagName;
}
public boolean isSwitchingTab() {
return switchingTab;
}
public void setSwitchingTab(boolean switchingTab) {
this.switchingTab = switchingTab;
}
private XWCardLayout cardLayout;
public XWCardTagLayout(WCardTagLayout widget, Dimension initSize){
@ -89,6 +99,10 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
*/
public void componentAdded(ContainerEvent e) {
super.componentAdded(e);
if (isSwitchingTab()){
return;
}
if(this.cardLayout == null){
initCardLayout();

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

@ -187,45 +187,48 @@ public class EditingMouseListener extends MouseInputAdapter {
designer.selectComponents(e);
}
if (stateModel.isDragging()) {
// 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(e.getX(), e.getY());
if(designer.isWidgetsIntersect() && dragBackupBounds != null && hoveredComponent != null){
XCreator selectionXCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
if(selectionXCreator != null){
selectionXCreator.setBounds(dragBackupBounds.x, dragBackupBounds.y, dragBackupBounds.width, dragBackupBounds.height);
MoveUtils.hideForbidWindow();
}
}
dragBackupBounds = null;
// 拉伸时鼠标拖动过快,导致所在组件获取会为空
if (hoveredComponent == null && e.getY() < 0) {
// bug63538
// 不是拖动过快导致的,而是纵坐标为负值导致的,这时参照横坐标为负值时的做法,取边界位置的组件,为鼠标所在点的组件
// 如果直接return,界面上已经进行了拖拽不能恢复
hoveredComponent = designer.getComponentAt(0, 0);
}
// 获取该组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
if (container != null) {
boolean formSubmit2Adapt = !selectionModel.getSelection().getSelectedCreator().canEnterIntoAdaptPane()
&& container.acceptType(XWFitLayout.class);
if ( !formSubmit2Adapt) {
// 如果是处于拖拽状态,则释放组件
stateModel.releaseDragging(e);
} else {
selectionModel.deleteSelection();
designer.setPainter(null);
}
cancelPromptWidgetForbidEnter();
}
mouseDraggingRelease(e);
}
}
lastPressEvent = null;
last_creator = null;
}
private void mouseDraggingRelease(MouseEvent e) {
// 当前鼠标所在的组件
XCreator hoveredComponent = designer.getComponentAt(e.getX(), e.getY());
if(designer.isWidgetsIntersect() && dragBackupBounds != null && hoveredComponent != null){
XCreator selectionXCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
if(selectionXCreator != null){
selectionXCreator.setBounds(dragBackupBounds.x, dragBackupBounds.y, dragBackupBounds.width, dragBackupBounds.height);
MoveUtils.hideForbidWindow();
}
}
dragBackupBounds = null;
// 拉伸时鼠标拖动过快,导致所在组件获取会为空
if (hoveredComponent == null && e.getY() < 0) {
// bug63538
// 不是拖动过快导致的,而是纵坐标为负值导致的,这时参照横坐标为负值时的做法,取边界位置的组件,为鼠标所在点的组件
// 如果直接return,界面上已经进行了拖拽不能恢复
hoveredComponent = designer.getComponentAt(0, 0);
}
// 获取该组件所在的焦点容器
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent);
if (container != null) {
boolean formSubmit2Adapt = !selectionModel.getSelection().getSelectedCreator().canEnterIntoAdaptPane()
&& container.acceptType(XWFitLayout.class);
if ( !formSubmit2Adapt) {
// 如果是处于拖拽状态,则释放组件
stateModel.releaseDragging(e);
} else {
selectionModel.deleteSelection();
designer.setPainter(null);
}
cancelPromptWidgetForbidEnter();
}
}
/**
* 激活上下文菜单待完善
* 6.56暂时不支持右键 bugid 8777
@ -286,33 +289,7 @@ public class EditingMouseListener extends MouseInputAdapter {
}
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() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minY = button.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue();
if (e.getX() + GAP - xElementCase.getInsets().left > minX && e.getX() - GAP - xElementCase.getInsets().left < minX + button.getWidth()) {
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.setHelpBtnOnFocus(false);
if (xElementCase.getCoverPane().getComponentCount() > 1) {
JComponent button1 = (JComponent) xElementCase.getCoverPane().getComponent(1);
int minX1 = button1.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minY1 = button1.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue();
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);
elementCaseMouseMoved(e, component);
designer.repaint();
return;
}
@ -322,6 +299,35 @@ public class EditingMouseListener extends MouseInputAdapter {
designer.repaint();
}
private void elementCaseMouseMoved(MouseEvent e, XCreator component) {
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() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minY = button.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue();
if (e.getX() + GAP - xElementCase.getInsets().left > minX && e.getX() - GAP - xElementCase.getInsets().left < minX + button.getWidth()) {
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.setHelpBtnOnFocus(false);
if (xElementCase.getCoverPane().getComponentCount() > 1) {
JComponent button1 = (JComponent) xElementCase.getCoverPane().getComponent(1);
int minX1 = button1.getX() + getParentPositionX(component, 0) - designer.getArea().getHorizontalValue();
int minY1 = button1.getY() + getParentPositionY(component, 0) - designer.getArea().getVerticalValue();
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);
}
private void setCoverPaneNotDisplay(MouseEvent e, boolean isLinkedHelpDialog) {
if (xElementCase != null) {
int x = getParentPositionX(xElementCase, 0) - designer.getArea().getHorizontalValue();
@ -511,9 +517,6 @@ public class EditingMouseListener extends MouseInputAdapter {
* @param e 鼠标事件
*/
public void mouseClicked(MouseEvent e) {
if (e.getButton() != MouseEvent.BUTTON1) {
return;
}
XCreator creator = designer.getComponentAt(e);
creator = processTopLayoutMouseClick(creator);

Loading…
Cancel
Save