Browse Source

REPORT-60887 MAC OS x电脑上 编辑按钮飘移

zheng-1641779399395
hades 3 years ago
parent
commit
6026f0d575
  1. 3
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  2. 47
      designer-form/src/main/java/com/fr/design/designer/ui/PopupDialogContext.java
  3. 17
      designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java

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

@ -11,6 +11,7 @@ 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.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.designer.ui.PopupDialogContext;
import com.fr.design.designer.ui.SelectedPopupDialog; import com.fr.design.designer.ui.SelectedPopupDialog;
import com.fr.design.fun.ShareWidgetUIProcessor; import com.fr.design.fun.ShareWidgetUIProcessor;
import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.WidgetPropertyUIProvider;
@ -778,6 +779,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
if (popup == null) { if (popup == null) {
popup = new SelectedPopupDialog(this, designer); popup = new SelectedPopupDialog(this, designer);
} }
PopupDialogContext.checkSelectedPop(this);
JFrame frame = LogMessageBar.getInstance().getLogFrame(); JFrame frame = LogMessageBar.getInstance().getLogFrame();
if (frame!= null && frame.isActive()) { if (frame!= null && frame.isActive()) {
return; return;
@ -876,6 +878,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
if (popup != null) { if (popup != null) {
popup.setVisible(false); popup.setVisible(false);
} }
PopupDialogContext.checkSelectedPop(this);
} }
public void processPopup(boolean canVisible) { public void processPopup(boolean canVisible) {

47
designer-form/src/main/java/com/fr/design/designer/ui/PopupDialogContext.java

@ -0,0 +1,47 @@
package com.fr.design.designer.ui;
import com.fr.design.designer.creator.XCreator;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* 把弹窗统一管理起来 防止出现异常情况下游离的弹窗
*
* @author hades
* @version 10.0
* Created by hades on 2021/11/02
*/
public class PopupDialogContext {
private static List<SelectedPopupDialog> dialogs = new ArrayList<>();
public static void add(SelectedPopupDialog selectedPopupDialog) {
if (dialogs.contains(selectedPopupDialog)) {
return;
}
dialogs.add(selectedPopupDialog);
}
public static void remove(SelectedPopupDialog selectedPopupDialog) {
dialogs.remove(selectedPopupDialog);
}
public static void checkSelectedPop(XCreator creator) {
Iterator<SelectedPopupDialog> iterator = dialogs.iterator();
List<SelectedPopupDialog> removedDialog = new ArrayList<>();
while (iterator.hasNext()) {
SelectedPopupDialog dialog = iterator.next();
if (dialog.isVisible() && creator != dialog.getCreator()) {
iterator.remove();
removedDialog.add(dialog);
}
}
for (SelectedPopupDialog dialog : removedDialog) {
dialog.setVisible(false);
}
}
}

17
designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java

@ -25,11 +25,14 @@ public class SelectedPopupDialog extends JDialog {
private boolean canVisible = true; private boolean canVisible = true;
private final XCreator creator;
public SelectedPopupDialog(XCreator creator, FormDesigner designer) { public SelectedPopupDialog(XCreator creator, FormDesigner designer) {
super(OperatingSystem.isMacos() ? new JFrame() : DesignerContext.getDesignerFrame()); super(OperatingSystem.isMacos() ? new JFrame() : DesignerContext.getDesignerFrame());
this.setUndecorated(true); this.setUndecorated(true);
this.setModal(false); this.setModal(false);
this.setFocusableWindowState(false); this.setFocusableWindowState(false);
this.creator = creator;
controlPanel = new PopupControlPanel(creator, designer); controlPanel = new PopupControlPanel(creator, designer);
this.getContentPane().add(controlPanel); this.getContentPane().add(controlPanel);
this.setSize(controlPanel.getDefaultDimension()); this.setSize(controlPanel.getDefaultDimension());
@ -44,6 +47,16 @@ public class SelectedPopupDialog extends JDialog {
return controlPanel.hasVisibleButtons(); return controlPanel.hasVisibleButtons();
} }
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
if (visible) {
PopupDialogContext.add(this);
} else {
PopupDialogContext.remove(this);
}
}
public void setRelativeBounds(Rectangle rectangle) { public void setRelativeBounds(Rectangle rectangle) {
this.controlPanel.setRelativeBounds(rectangle); this.controlPanel.setRelativeBounds(rectangle);
} }
@ -55,4 +68,8 @@ public class SelectedPopupDialog extends JDialog {
public void setCanVisible(boolean canVisible) { public void setCanVisible(boolean canVisible) {
this.canVisible = canVisible; this.canVisible = canVisible;
} }
public XCreator getCreator() {
return this.creator;
}
} }

Loading…
Cancel
Save