Browse Source

Pull request #7647: REPORT-65989 frm报表块内10.0模板在11.0设计器打开后无法使用鼠标滚轮滑动

Merge in DESIGN/design from ~STARRYI/design:feature/x to feature/x

* commit '83d78aaa9136f8101c3cb92f268070e4e36197f9':
  REPORT-65989 frm报表块内10.0模板在11.0设计器打开后无法使用鼠标滚轮滑动
feature/x
starryi 3 years ago
parent
commit
4bb83cbbd5
  1. 19
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormReportComponentComposite.java
  2. 79
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormReportComponentCompositeMouseWheelHandler.java
  3. 25
      designer-realize/src/main/java/com/fr/design/share/ui/effect/PreviewPane.java
  4. 69
      designer-realize/src/main/java/com/fr/design/share/ui/effect/PreviewPaneMouseWheelHandler.java

19
designer-realize/src/main/java/com/fr/design/mainframe/form/FormReportComponentComposite.java

@ -12,6 +12,8 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerUIModeConfig;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JFormSliderPane;
import com.fr.design.mainframe.ReportComponent;
import com.fr.design.mainframe.ReportComponentCompositeMouseWheelHandler;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.form.FormElementCaseContainerProvider;
import com.fr.form.FormElementCaseProvider;
@ -53,23 +55,11 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
sheetNameTab = new FormTabPane(ecContainer, jform);
this.add(createSouthControlPane(), BorderLayout.SOUTH);
jSliderContainer.addValueChangeListener(showValSpinnerChangeListener);
this.elementCaseDesigner.elementCasePane.getGrid().addMouseWheelListener(showValSpinnerMouseWheelListener);
this.elementCaseDesigner.elementCasePane.getGrid().addMouseWheelListener(new FormReportComponentCompositeMouseWheelHandler(this));
elementCaseDesigner.addTargetModifiedListener(this);
this.jSliderContainer.setShowValue((ScreenResolution.getScreenResolution() * HUND) / Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION);
}
MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (InputEventBaseOnOS.isControlDown(e)) {
int dir = e.getWheelRotation();
int old_resolution = jSliderContainer.getShowValue();
jSliderContainer.setShowValue(old_resolution - (dir * DIR));
}
}
};
ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
@ -195,5 +185,8 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
jForm.fireTargetModified();
}
public JFormSliderPane getSliderContainer() {
return this.jSliderContainer;
}
}

79
designer-realize/src/main/java/com/fr/design/mainframe/form/FormReportComponentCompositeMouseWheelHandler.java

@ -0,0 +1,79 @@
package com.fr.design.mainframe.form;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.mainframe.DesignerScaleMouseWheelHandler;
import com.fr.design.mainframe.DesignerTranslateMouseWheelHandler;
import com.fr.design.mainframe.JFormSliderPane;
import com.fr.design.mainframe.ReportComponentComposite;
import javax.swing.JScrollBar;
import javax.swing.JViewport;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/9/24
*/
public class FormReportComponentCompositeMouseWheelHandler implements MouseWheelListener {
private final DesignerTranslateMouseWheelHandler translateMouseWheelHandler;
private final DesignerScaleMouseWheelHandler scaleMouseWheelHandler;
public FormReportComponentCompositeMouseWheelHandler(FormReportComponentComposite componentComposite) {
translateMouseWheelHandler = new DesignerTranslateMouseWheelHandler(new ScrollPaneAdapter(componentComposite));
scaleMouseWheelHandler = new DesignerScaleMouseWheelHandler(new ScalePaneAdapter(componentComposite), ReportComponentComposite.DIR);
}
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (InputEventBaseOnOS.isControlDown(e)) {
scaleMouseWheelHandler.mouseWheelMoved(e);
} else {
translateMouseWheelHandler.mouseWheelMoved(e);
}
}
private static class ScrollPaneAdapter implements DesignerTranslateMouseWheelHandler.ScrollPane {
private final FormReportComponentComposite componentComposite;
private JViewport viewport;
public ScrollPaneAdapter(FormReportComponentComposite componentComposite) {
this.componentComposite = componentComposite;
this.viewport = new JViewport();
}
@Override
public boolean isWheelScrollingEnabled() {
return true;
}
@Override
public JScrollBar getVerticalScrollBar() {
return componentComposite.elementCaseDesigner.getVerticalScrollBar();
}
@Override
public JScrollBar getHorizontalScrollBar() {
return componentComposite.elementCaseDesigner.getHorizontalScrollBar();
}
@Override
public JViewport getViewport() {
return viewport;
}
}
private static class ScalePaneAdapter implements DesignerScaleMouseWheelHandler.ScalePane {
private final FormReportComponentComposite componentComposite;
public ScalePaneAdapter(FormReportComponentComposite componentComposite) {
this.componentComposite = componentComposite;
}
@Override
public JFormSliderPane getSlidePane() {
return componentComposite.getSliderContainer();
}
}
}

25
designer-realize/src/main/java/com/fr/design/share/ui/effect/PreviewPane.java

@ -70,7 +70,6 @@ public class PreviewPane extends JPanel implements CallbackEvent{
private static final int MAX = 400;
private static final int HUND = 100;
private static final int MIN = 10;
private static final int DIR = 10;
private static final double MIN_TIME = 0.4;
private Widget widget;
@ -194,27 +193,7 @@ public class PreviewPane extends JPanel implements CallbackEvent{
grid.removeMouseMotionListener(grid.getGridMouseAdapter());
grid.removeMouseListener(grid.getGridMouseAdapter());
grid.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (!InputEventBaseOnOS.isControlDown(e)) {
ElementCasePane reportPane = grid.getElementCasePane();
if (reportPane.isVerticalScrollBarVisible()) {
JScrollBar scrollBar = reportPane.getVerticalScrollBar();
int maxValue = scrollBar.getModel().getMaximum();
int newValue = reportPane.getVerticalScrollBar().getValue() + e.getWheelRotation();
int extendValue = GridUtils.getExtentValue(newValue, elementCase.getRowHeightList_DEC(), grid.getHeight(), getResolution());
if (extendValue <= maxValue) {
reportPane.getVerticalScrollBar().setValue(newValue);
}
}
} else {
int dir = e.getWheelRotation();
addScale( - dir * DIR);
grid.setCursor(SCALE_CURSOR);
}
}
});
grid.addMouseWheelListener(new PreviewPaneMouseWheelHandler(this));
grid.addMouseMotionListener(new MouseMotionAdapter() {
@Override
@ -320,7 +299,7 @@ public class PreviewPane extends JPanel implements CallbackEvent{
elementCasePane.repaint();
}
private void addScale(int step) {
public void addScale(int step) {
scaleValue += step;
scaleValue = fixedScale(scaleValue);
plusButton.setEnabled(scaleValue < MAX);

69
designer-realize/src/main/java/com/fr/design/share/ui/effect/PreviewPaneMouseWheelHandler.java

@ -0,0 +1,69 @@
package com.fr.design.share.ui.effect;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.mainframe.DesignerTranslateMouseWheelHandler;
import javax.swing.JScrollBar;
import javax.swing.JViewport;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import static com.fr.design.share.ui.effect.PreviewPane.SCALE_CURSOR;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/9/24
*/
public class PreviewPaneMouseWheelHandler implements MouseWheelListener {
private static final int DIR = 10;
private final DesignerTranslateMouseWheelHandler translateMouseWheelHandler;
private final PreviewPane previewPane;
public PreviewPaneMouseWheelHandler(PreviewPane previewPane) {
this.translateMouseWheelHandler = new DesignerTranslateMouseWheelHandler(new PreviewPaneScrollPaneAdapter(previewPane));
this.previewPane = previewPane;
}
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (InputEventBaseOnOS.isControlDown(e)) {
int dir = e.getWheelRotation();
previewPane.addScale( - dir * DIR);
previewPane.getElementCasePane().getGrid().setCursor(SCALE_CURSOR);
} else {
translateMouseWheelHandler.mouseWheelMoved(e);
}
}
private static class PreviewPaneScrollPaneAdapter implements DesignerTranslateMouseWheelHandler.ScrollPane {
private final PreviewPane previewPane;
private final JViewport viewport;
public PreviewPaneScrollPaneAdapter(PreviewPane previewPane) {
this.previewPane = previewPane;
this.viewport = new JViewport();
}
@Override
public boolean isWheelScrollingEnabled() {
return true;
}
@Override
public JScrollBar getVerticalScrollBar() {
return previewPane.getElementCasePane().getVerticalScrollBar();
}
@Override
public JScrollBar getHorizontalScrollBar() {
return previewPane.getElementCasePane().getHorizontalScrollBar();
}
@Override
public JViewport getViewport() {
return this.viewport;
}
}
}
Loading…
Cancel
Save