diff --git a/designer_base/src/com/fr/design/editor/ValueEditorPaneFactory.java b/designer_base/src/com/fr/design/editor/ValueEditorPaneFactory.java index 29ee9e60a6..e63b3c9741 100644 --- a/designer_base/src/com/fr/design/editor/ValueEditorPaneFactory.java +++ b/designer_base/src/com/fr/design/editor/ValueEditorPaneFactory.java @@ -202,7 +202,7 @@ public class ValueEditorPaneFactory { FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("Parameter-Formula")); return new Editor[]{ new TextEditor(), - new IntegerEditor(), + new SpinnerIntegerEditor(), new DoubleEditor(), new DateEditor(true, Inter.getLocText("Date")), new BooleanEditor(), diff --git a/designer_base/src/com/fr/design/editor/editor/SpinnerIntegerEditor.java b/designer_base/src/com/fr/design/editor/editor/SpinnerIntegerEditor.java new file mode 100644 index 0000000000..2366350f69 --- /dev/null +++ b/designer_base/src/com/fr/design/editor/editor/SpinnerIntegerEditor.java @@ -0,0 +1,66 @@ +package com.fr.design.editor.editor; + +import com.fr.base.Utils; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.Inter; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +public class SpinnerIntegerEditor extends Editor { + + private UISpinner spinner; + private String oldValue = StringUtils.EMPTY; + + public SpinnerIntegerEditor(){ + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + spinner = new UISpinner(-Integer.MAX_VALUE, Integer.MAX_VALUE, 1, 0); + this.add(spinner, BorderLayout.CENTER); + this.spinner.addKeyListener(textKeyListener); + this.setName(Inter.getLocText("Parameter-Integer")); + } + + @Override + public Integer getValue() { + return new Integer((int) this.spinner.getValue()); + } + + @Override + public void setValue(Integer value) { + if (value == null) { + value = new Integer(0); + } + this.spinner.setValue(value.intValue()); + oldValue = Utils.objectToString(value); + } + + @Override + public boolean accept(Object object) { + return object != null && object instanceof Integer; + } + + public String getIconName() { + return "type_int"; + } + + KeyListener textKeyListener = new KeyAdapter() { + + public void keyReleased(KeyEvent evt) { + int code = evt.getKeyCode(); + + if (code == KeyEvent.VK_ESCAPE) { + spinner.setValue(Double.parseDouble(oldValue)); + } + if (code == KeyEvent.VK_ENTER) { + fireEditingStopped(); + } else { + fireStateChanged(); + } + } + }; +}