Browse Source

Pull request #4976: REPORT-55178 && REPORT-55188 && REPORT-55228 && REPORT-55212

Merge in DESIGN/design from ~HADES/design:release/10.0 to release/10.0

* commit '31a95fba76ed4608b66da2bb550ab5d0b064ec48':
  REPORT-55228 【组件背景分离】组件复用-打开其他模板 工具栏会留在设计页面上
  REPORT-55212 【组件背景分离】组件复用-tab里的图表块和报表块无法通过点击原本的编辑按钮和双击触发编辑状态 工具栏的编辑按钮可以触发 && REPORT-55228 【组件背景分离】组件复用 打开其他模板 工具栏会留在设计页面上
  REPORT-55188 【组件背景分离】组件复用-设计器右侧组件目录树选中组件应也触发绝对布局下组件的工具栏 update
  REPORT-55188 【组件背景分离】组件复用-设计器右侧组件目录树选中组件应也触发绝对布局下组件的工具栏
  REPORT-55178 【组件背景分离】组件复用-设计界面,现在需要点两下选中组件才能出现工具栏
zheng-1641779399395
Hades 3 years ago
parent
commit
5fc8fa84f9
  1. 6
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  2. 49
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  3. 11
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  4. 27
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java

6
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -830,4 +830,10 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
}
}
public void hidePopup() {
if (popup != null) {
popup.setVisible(false);
}
}
}

49
designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java

@ -4,6 +4,7 @@ import com.fr.design.constants.UIConstants;
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.XWTitleLayout;
import com.fr.design.designer.treeview.ComponentTreeCellRenderer;
import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.file.HistoryTemplateListCache;
@ -16,6 +17,7 @@ import com.fr.stable.StringUtils;
import java.awt.Rectangle;
import java.awt.event.MouseListener;
import java.util.Stack;
import java.util.function.Consumer;
import javax.swing.BorderFactory;
import javax.swing.DropMode;
import javax.swing.JPanel;
@ -349,6 +351,7 @@ public class ComponentTree extends JTree {
private final class ComponetTreeMouseListener extends MouseAdapter {
private final JTree tree;
private XCreator selectedCreator;
private ComponetTreeMouseListener(JTree tree) {
this.tree = tree;
@ -378,8 +381,49 @@ public class ComponentTree extends JTree {
@Override
public void mouseClicked(MouseEvent e) {
// 鼠标左键 双击
onMouseEvent(e, new Consumer<XCreator>() {
@Override
public void accept(XCreator creator) {
if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !designer.isFormParaDesigner()) {
startEditing(creator, e);
}
}
});
}
@Override
public void mousePressed(MouseEvent e) {
onMouseEvent(e, new Consumer<XCreator>() {
@Override
public void accept(XCreator creator) {
if (e.getButton() == MouseEvent.BUTTON1) {
selectedCreator = creator;
}
}
});
}
@Override
public void mouseReleased(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1 && selectedCreator != null) {
showSelectedPopup(selectedCreator);
}
}
private void showSelectedPopup(XCreator comp) {
Rectangle rectangle = getRelativeBounds(comp);
comp.showSelectedPopup(designer, rectangle, comp.acceptType(XWTitleLayout.class));
comp.setSelected(true);
}
/**
* 响应鼠标事件并解析选中的组件
*
* @param e
* @param consumer
*/
private void onMouseEvent(final MouseEvent e, Consumer<XCreator> consumer) {
Point p = e.getPoint();
// 解析组件树路径 获取选中的组件
int selRow = tree.getRowForLocation(p.x, p.y);
@ -389,8 +433,7 @@ public class ComponentTree extends JTree {
Point point = bounds.getLocation();
SwingUtilities.convertPointToScreen(point, tree);
XCreator comp = (XCreator) path.getLastPathComponent();
startEditing(comp, e);
}
consumer.accept(comp);
}
}

11
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -624,6 +624,8 @@ public class EditingMouseListener extends MouseInputAdapter {
creator = processTopLayoutMouseClick(creator);
if (creator != null) {
// tab块处于未编辑状态
boolean uneditedTab = designer.getCursor().getType() != Cursor.HAND_CURSOR && creator.acceptType(XWCardMainBorderLayout.class) && !((XWCardMainBorderLayout) creator).isEditable();
// 点击不在tab块的button中
boolean clickedNonCardButton = !creator.acceptType(XCardAddButton.class, XCardSwitchButton.class);
if (clickedNonCardButton && e.getClickCount() == 1 && designer.getCursor().getType() != Cursor.HAND_CURSOR) {
@ -631,10 +633,17 @@ public class EditingMouseListener extends MouseInputAdapter {
selectionModel.selectACreatorAtMouseEvent(e);
refreshTopXCreator();
XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators();
// 放到事件队尾执行
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (XCreator xCreator : xCreators) {
xCreator.setSelected(true);
}
} else if (clickedNonCardButton && responseTabLayout(oldCreator, e)) {
}
});
} else if (clickedNonCardButton && uneditedTab && responseTabLayout(oldCreator, e)) {
// do nothing
} else {
creator.respondClick(this, e);

27
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -47,8 +47,6 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.form.FormECCompositeProvider;
import com.fr.design.mainframe.form.FormECDesignerProvider;
import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.util.ShareComponentUtils;
import com.fr.design.mainframe.template.info.JFormProcessInfo;
import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
@ -79,10 +77,8 @@ import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONArray;
import com.fr.log.FineLoggerFactory;
import com.fr.page.PaperSettingProvider;
import com.fr.plugin.observer.PluginEventListener;
import com.fr.report.cell.Elem;
import com.fr.report.cell.cellattr.CellImage;
import com.fr.report.worksheet.FormElementCase;
@ -93,6 +89,8 @@ import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory;
import com.fr.web.controller.ViewRequestConstants;
import java.awt.event.ContainerAdapter;
import java.awt.event.ContainerEvent;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent;
@ -135,18 +133,36 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
//FORM_TAB代表是否点击编辑,用于点击编辑前后菜单的显示
protected int index = FORM_TAB;
private PluginEventListener pluginListener;
private ContainerAdapter containerAdapter = new ContainerAdapter() {
@Override
public void componentRemoved(ContainerEvent e) {
// 当前jfrom未在tab中显示时
if (formDesign != null) {
XCreator[] creators = formDesign.getSelectionModel().getSelection().getSelectedCreators();
for (XCreator creator : creators) {
creator.hidePopup();
}
}
}
};
public JForm() {
super(new Form(new WBorderLayout("form")), "Form");
init();
}
public JForm(Form form, FILE file, Parameter[] parameters) {
super(form, file, parameters);
init();
}
public JForm(Form form, FILE file) {
super(form, file);
init();
}
private void init() {
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().addContainerListener(containerAdapter);
}
@Override
@ -1114,6 +1130,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
public void whenClose() {
super.whenClose();
this.releaseResources();
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().removeContainerListener(this.containerAdapter);
}
@Override

Loading…
Cancel
Save