Browse Source

REPORT-60798 在线获取主题右击组件包后异常

research/11.0
kuangshuai 3 years ago
parent
commit
4b744ae469
  1. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java
  2. 46
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java

2
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java

@ -58,7 +58,7 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
return null; return null;
} }
protected JPopupMenu getRightClickPopupMenu() { public JPopupMenu getRightClickPopupMenu() {
return rightClickPopupMenu; return rightClickPopupMenu;
} }

46
designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/theme/DownloadComponentPackageGuide.java

@ -40,10 +40,13 @@ import javax.swing.JDialog;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JPopupMenu; import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import java.awt.Component; import java.awt.Component;
import java.awt.Point; import java.awt.Point;
import java.awt.event.ContainerAdapter; import java.awt.event.ContainerAdapter;
import java.awt.event.ContainerEvent; import java.awt.event.ContainerEvent;
import java.util.List;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.UUID; import java.util.UUID;
@ -170,12 +173,29 @@ public class DownloadComponentPackageGuide {
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { scene.registerLifecycle(new GuideSceneLifecycleAdaptor() {
@Override @Override
public boolean prepared() { public boolean prepared() {
onlineWidgetPackageBlock = (OnlineWidgetPackageBlock) ComponentUtils.findComponentByClass(EastRegionContainerPane.getInstance(), OnlineWidgetPackageBlock.class); List<Component> components = ComponentUtils.findComponentsByClass(EastRegionContainerPane.getInstance(), OnlineWidgetPackageBlock.class);
if (onlineWidgetPackageBlock != null) { for (int index = 0; index < components.size(); index++) {
scene.addClickTarget(onlineWidgetPackageBlock, ClickScene.ClickType.RIGHT); OnlineWidgetPackageBlock block = (OnlineWidgetPackageBlock) components.get(index);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F002002_Tip_Right_Click_Package"), GuideTip.Direction.LEFT); if (StringUtils.isNotEmpty(block.getWidget().getThemePath())) {
onlineWidgetPackageBlock = block;
break;
}
} }
return true; if (onlineWidgetPackageBlock == null) {
GuideManager.getInstance().getCurrentGuide().terminate();
} else {
JScrollPane scrollPane = getParentScrollPane(onlineWidgetPackageBlock);
scrollPane.getVerticalScrollBar().setValue(onlineWidgetPackageBlock.getY());
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
scene.addClickTarget(onlineWidgetPackageBlock, ClickScene.ClickType.RIGHT);
scene.addBubbleTip(Toolkit.i18nText("Fine-Design_Guide_Scene_F002002_Tip_Right_Click_Package"), GuideTip.Direction.LEFT);
scene.showScene();
}
});
}
return false;
} }
}); });
return scene; return scene;
@ -187,7 +207,7 @@ public class DownloadComponentPackageGuide {
@Override @Override
public boolean prepared() { public boolean prepared() {
scene.addTarget(onlineWidgetPackageBlock); scene.addTarget(onlineWidgetPackageBlock);
JPopupMenu popupMenu = onlineWidgetPackageBlock.getComponentPopupMenu(); JPopupMenu popupMenu = onlineWidgetPackageBlock.getRightClickPopupMenu();
Point location = getPopupMenuLocation(); Point location = getPopupMenuLocation();
scene.addCustomTarget( scene.addCustomTarget(
GuideCreateUtils.createTarget(popupMenu), GuideCreateUtils.createTarget(popupMenu),
@ -204,7 +224,7 @@ public class DownloadComponentPackageGuide {
scene.registerLifecycle(new GuideSceneLifecycleAdaptor() { scene.registerLifecycle(new GuideSceneLifecycleAdaptor() {
@Override @Override
public boolean prepared() { public boolean prepared() {
JPopupMenu popupMenu = onlineWidgetPackageBlock.getComponentPopupMenu(); JPopupMenu popupMenu = onlineWidgetPackageBlock.getRightClickPopupMenu();
Point location = getPopupMenuLocation(); Point location = getPopupMenuLocation();
scene.addCustomTarget( scene.addCustomTarget(
GuideCreateUtils.createModalTarget(popupMenu), GuideCreateUtils.createModalTarget(popupMenu),
@ -279,7 +299,7 @@ public class DownloadComponentPackageGuide {
} }
private static Point getPopupMenuLocation() { private static Point getPopupMenuLocation() {
JPopupMenu popupMenu = onlineWidgetPackageBlock.getComponentPopupMenu(); JPopupMenu popupMenu = onlineWidgetPackageBlock.getRightClickPopupMenu();
return new Point((onlineWidgetPackageBlock.getWidth() - popupMenu.getWidth()) / 2, (onlineWidgetPackageBlock.getHeight()- popupMenu.getHeight()) / 2); return new Point((onlineWidgetPackageBlock.getWidth() - popupMenu.getWidth()) / 2, (onlineWidgetPackageBlock.getHeight()- popupMenu.getHeight()) / 2);
} }
@ -289,4 +309,14 @@ public class DownloadComponentPackageGuide {
} }
} }
private static JScrollPane getParentScrollPane(Component component) {
if (component.getParent() == null) {
return null;
}
if (component.getParent() instanceof JScrollPane) {
return (JScrollPane) component.getParent();
}
return getParentScrollPane(component.getParent());
}
} }

Loading…
Cancel
Save