Browse Source

REPORT-4634 组件叠加体验优化=>3=>右键菜单支持

master
plough 7 years ago
parent
commit
9b6a37ab1e
  1. 2
      designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java
  2. 3
      designer_form/src/com/fr/design/designer/creator/XChartEditor.java
  3. 19
      designer_form/src/com/fr/design/designer/creator/XCreator.java
  4. 3
      designer_form/src/com/fr/design/designer/creator/XElementCase.java
  5. 3
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java
  6. 3
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  7. 10
      designer_form/src/com/fr/design/mainframe/EditingMouseListener.java

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

@ -62,7 +62,7 @@ public class SelectionModel {
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void selectACreatorAtMouseEvent(MouseEvent e) { public void selectACreatorAtMouseEvent(MouseEvent e) {
if (!InputEventBaseOnOS.isControlDown(e) && !e.isShiftDown()) { if (e.getButton() == MouseEvent.BUTTON3 || (!InputEventBaseOnOS.isControlDown(e) && !e.isShiftDown())) {
// 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件 // 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件
selection.reset(); selection.reset();
} }

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

@ -206,7 +206,8 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); SelectionModel selectionModel = editingMouseListener.getSelectionModel();
isEditing = e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR; isEditing = e.getButton() == MouseEvent.BUTTON1 &&
(e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR);
displayCoverPane(!isEditing); displayCoverPane(!isEditing);
selectionModel.selectACreatorAtMouseEvent(e); selectionModel.selectACreatorAtMouseEvent(e);

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

@ -6,6 +6,7 @@ package com.fr.design.designer.creator;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.ComponentAdapter;
import com.fr.design.designer.beans.actions.*;
import com.fr.design.designer.beans.events.DesignerEditor; import com.fr.design.designer.beans.events.DesignerEditor;
import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.WidgetPropertyUIProvider;
@ -664,4 +665,22 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
// do nothing // do nothing
} }
/**
* 创建右击弹出菜单
*
*/
public JPopupMenu createPopupMenu(FormDesigner formDesigner) {
JPopupMenu popup = new JPopupMenu();
popup.add(new CutAction(formDesigner).createMenuItem());
popup.add(new CopyAction(formDesigner).createMenuItem());
popup.add(new PasteAction(formDesigner).createMenuItem());
popup.add(new FormDeleteAction(formDesigner).createMenuItem());
popup.addSeparator();
popup.add(new MoveToTopAction(formDesigner).createMenuItem());
popup.add(new MoveToBottomAction(formDesigner).createMenuItem());
popup.add(new MoveUpAction(formDesigner).createMenuItem());
popup.add(new MoveDownAction(formDesigner).createMenuItem());
return popup;
}
} }

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

@ -302,7 +302,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
private void switchTab(MouseEvent e,EditingMouseListener editingMouseListener){ private void switchTab(MouseEvent e,EditingMouseListener editingMouseListener){
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
if (e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR){ if (e.getButton() == MouseEvent.BUTTON1 &&
(e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR)){
FormElementCaseContainerProvider component = (FormElementCaseContainerProvider) designer.getComponentAt(e); FormElementCaseContainerProvider component = (FormElementCaseContainerProvider) designer.getComponentAt(e);
//切换设计器 //切换设计器
designer.switchTab(component); designer.switchTab(component);

3
designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -467,7 +467,8 @@ public class XWAbsoluteLayout extends XLayoutContainer {
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) { public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) {
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); SelectionModel selectionModel = editingMouseListener.getSelectionModel();
boolean isEditing = isEditable() || designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2; boolean isEditing = isEditable() ||
e.getButton() == MouseEvent.BUTTON1 && (designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2);
setEditable(isEditing); setEditable(isEditing);
selectionModel.selectACreatorAtMouseEvent(e); selectionModel.selectACreatorAtMouseEvent(e);

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

@ -246,7 +246,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout{
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); SelectionModel selectionModel = editingMouseListener.getSelectionModel();
boolean isEditing = designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2; boolean isEditing = e.getButton() == MouseEvent.BUTTON1 &&
(designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2);
setEditable(isEditing); setEditable(isEditing);
selectionModel.selectACreatorAtMouseEvent(e); selectionModel.selectACreatorAtMouseEvent(e);

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

@ -17,6 +17,7 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.xpane.ToolTipEditor; import com.fr.design.gui.xpane.ToolTipEditor;
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.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.LayoutUtils; 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;
@ -528,8 +529,9 @@ public class EditingMouseListener extends MouseInputAdapter {
*/ */
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
XCreator creator = designer.getComponentAt(e); XCreator creator = designer.getComponentAt(e);
boolean isValidButton = e.getButton() == MouseEvent.BUTTON1 || e.getButton() == MouseEvent.BUTTON3;
if (e.getButton() != MouseEvent.BUTTON1 && !creator.acceptType(XCardSwitchButton.class)) { if (!isValidButton && !creator.acceptType(XCardSwitchButton.class)) {
return; return;
} }
@ -537,6 +539,12 @@ public class EditingMouseListener extends MouseInputAdapter {
if (creator != null) { if (creator != null) {
creator.respondClick(this, e); creator.respondClick(this, e);
if (e.getButton() == MouseEvent.BUTTON3) {
JPopupMenu cellPopupMenu = creator.createPopupMenu(designer);
if (cellPopupMenu != null) {
GUICoreUtils.showPopupMenu(cellPopupMenu, designer, e.getX(), e.getY());
}
}
} }
creator.doLayout(); creator.doLayout();
LayoutUtils.layoutRootContainer(designer.getRootComponent()); LayoutUtils.layoutRootContainer(designer.getRootComponent());

Loading…
Cancel
Save