Author: tmorgner Date: 2011-07-28 07:57:40 -0400 (Thu, 28 Jul 2011) New Revision: 14194 Modified: engines/classic/branches/3.8/core/source/org/pentaho/reporting/engine/classic/core/modules/gui/print/PageSetupDialog.java Log: PRD-3537: After changing the orientation from portrait to landscape, the right and left margins get reversed. This case heavily relates to PRD-3425. Modified: engines/classic/branches/3.8/core/source/org/pentaho/reporting/engine/classic/core/modules/gui/print/PageSetupDialog.java =================================================================== --- engines/classic/branches/3.8/core/source/org/pentaho/reporting/engine/classic/core/modules/gui/print/PageSetupDialog.java 2011-07-28 11:57:21 UTC (rev 14193) +++ engines/classic/branches/3.8/core/source/org/pentaho/reporting/engine/classic/core/modules/gui/print/PageSetupDialog.java 2011-07-28 11:57:40 UTC (rev 14194) @@ -9,24 +9,29 @@ import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; import java.awt.print.PageFormat; import java.awt.print.Paper; import java.util.Locale; import javax.swing.AbstractAction; import javax.swing.Action; +import javax.swing.ActionMap; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; import javax.swing.DefaultComboBoxModel; import javax.swing.Icon; +import javax.swing.InputMap; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; +import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.KeyStroke; import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -35,21 +40,12 @@ import org.pentaho.reporting.engine.classic.core.PageDefinition; import org.pentaho.reporting.engine.classic.core.SimplePageDefinition; -import org.pentaho.reporting.engine.classic.core.modules.gui.base.SwingPreviewModule; import org.pentaho.reporting.engine.classic.core.modules.gui.common.GuiContext; import org.pentaho.reporting.engine.classic.core.util.PageFormatFactory; import org.pentaho.reporting.libraries.base.util.ObjectUtilities; import org.pentaho.reporting.libraries.base.util.ResourceBundleSupport; import org.pentaho.reporting.libraries.xmlns.common.ParserUtil; -/** - * Todo: Document me! - * <p/> - * Date: 13.10.2009 - * Time: 13:51:11 - * - * @author Thomas Morgner. - */ public class PageSetupDialog extends JDialog { protected class ConfirmAction extends AbstractAction @@ -307,6 +303,15 @@ contentPane.add(createContentPane(), BorderLayout.CENTER); contentPane.add(createButtonsPane(), BorderLayout.SOUTH); setContentPane(contentPane); + + final InputMap inputMap = contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); + final ActionMap actionMap = contentPane.getActionMap(); + + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "confirm"); // NON-NLS + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); // NON-NLS + actionMap.put("confirm", confirmAction); // NON-NLS + actionMap.put("cancel", new CancelAction()); // NON-NLS + pack(); } @@ -734,9 +739,9 @@ else { marginTopField.setText(String.valueOf(pageFormatFactory.getLeftBorder(paper))); - marginLeftField.setText(String.valueOf(pageFormatFactory.getTopBorder(paper))); + marginLeftField.setText(String.valueOf(pageFormatFactory.getBottomBorder(paper))); marginBottomField.setText(String.valueOf(pageFormatFactory.getRightBorder(paper))); - marginRightField.setText(String.valueOf(pageFormatFactory.getBottomBorder(paper))); + marginRightField.setText(String.valueOf(pageFormatFactory.getTopBorder(paper))); } } @@ -761,7 +766,7 @@ else { //noinspection SuspiciousNameCombination - PageFormatFactory.getInstance().setBorders(p, marginLeft, marginTop, marginRight, marginBottom); + PageFormatFactory.getInstance().setBorders(p, marginRight, marginTop, marginLeft, marginBottom); pf = PageFormatFactory.getInstance().createPageFormat(p, PageFormat.LANDSCAPE); } |