Example usage for javax.swing SpinnerNumberModel SpinnerNumberModel

List of usage examples for javax.swing SpinnerNumberModel SpinnerNumberModel

Introduction

In this page you can find the example usage for javax.swing SpinnerNumberModel SpinnerNumberModel.

Prototype

public SpinnerNumberModel(double value, double minimum, double maximum, double stepSize) 

Source Link

Document

Constructs a SpinnerNumberModel with the specified value, minimum/maximum bounds, and stepSize.

Usage

From source file:org.esa.s1tbx.ocean.worldwind.layers.Level2ProductLayer.java

public JPanel getControlPanel(final WorldWindowGLCanvas wwd) {
    theControlLevel2Panel = new JPanel(new GridLayout(7, 1, 5, 5));
    theControlLevel2Panel.setVisible(false);
    final JRadioButton owiBtn = new JRadioButton("OWI");
    owiBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            theSelectedComp = "owi";
            setComponentVisible("owi", wwd);
            theArrowsCB.setEnabled(true);
        }/*ww  w .ja  va  2  s .  c  om*/
    });

    final JRadioButton oswBtn = new JRadioButton("OSW");
    oswBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            theSelectedComp = "osw";
            setComponentVisible("osw", wwd);
            theArrowsCB.setEnabled(false);

            //SystemUtils.LOG.info("theSurfaceProductHash " + theSurfaceProductHash);
            //SystemUtils.LOG.info("theSurfaceSequenceHash " + theSurfaceSequenceHash);
        }
    });

    final JRadioButton rvlBtn = new JRadioButton("RVL");
    rvlBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            theSelectedComp = "rvl";
            //System.out.println("rvl:");
            //setComponentVisible("owi", false, getWwd());
            //setComponentVisible("osw", false, getWwd());
            setComponentVisible("rvl", wwd);
            theArrowsCB.setEnabled(false);
        }
    });

    final ButtonGroup group = new ButtonGroup();
    group.add(owiBtn);
    group.add(oswBtn);
    group.add(rvlBtn);
    owiBtn.setSelected(true);

    theSelectedComp = "owi";

    final JPanel componentTypePanel = new JPanel(new GridLayout(1, 4, 5, 5));
    componentTypePanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    componentTypePanel.add(new JLabel("Component:"));
    componentTypePanel.add(owiBtn);
    componentTypePanel.add(oswBtn);
    componentTypePanel.add(rvlBtn);
    theControlLevel2Panel.add(componentTypePanel);

    final JPanel arrowDisplayPanel = new JPanel(new GridLayout(1, 2, 5, 5));

    theArrowsCB = new JCheckBox(new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
            // Simply enable or disable the layer based on its toggle button.
            if (((JCheckBox) actionEvent.getSource()).isSelected())
                theOWIArrowsDisplayed = true;
            else
                theOWIArrowsDisplayed = false;

            wwd.redrawNow();
        }
    });

    arrowDisplayPanel.add(new JLabel("Display Wind Vectors:"));
    arrowDisplayPanel.add(theArrowsCB);
    theControlLevel2Panel.add(arrowDisplayPanel);

    /*
    final JPanel subsectionPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    JComboBox sectionDropDown = new JComboBox();
    sectionDropDown.addItem("001");
    sectionDropDown.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        SystemUtils.LOG.info("drop down changed");
    }
    });
            
    subsectionPanel.add(new JLabel("Subsection:"));
    subsectionPanel.add(sectionDropDown);
            
    theControlLevel2Panel.add(subsectionPanel);
    */

    final JPanel maxPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    maxPanel.add(new JLabel("Max OWI Wind Speed:"));

    final JSpinner maxSP = new JSpinner(new SpinnerNumberModel(10, 0, 10, 1));
    maxSP.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            int newValue = (Integer) ((JSpinner) e.getSource()).getValue();

            theOWILimitChanged = true;
        }
    });
    maxPanel.add(maxSP);
    theControlLevel2Panel.add(maxPanel);

    final JPanel minPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    minPanel.add(new JLabel("Min OWI Wind Speed:"));

    final JSpinner minSP = new JSpinner(new SpinnerNumberModel(0, 0, 10, 1));
    minSP.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            theOWILimitChanged = true;
        }
    });
    minPanel.add(minSP);
    theControlLevel2Panel.add(minPanel);

    final JPanel maxRVLPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    maxRVLPanel.add(new JLabel("Max RVL Rad Vel.:"));

    final JSpinner maxRVLSP = new JSpinner(new SpinnerNumberModel(6, 0, 10, 1));
    maxRVLSP.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            int newValue = (Integer) ((JSpinner) e.getSource()).getValue();
            theRVLLimitChanged = true;
        }
    });
    maxRVLPanel.add(maxRVLSP);
    theControlLevel2Panel.add(maxRVLPanel);

    final JButton updateButton = new JButton("Update");
    updateButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {

            if (theOWILimitChanged) {

                //double minValue = ((Integer) minSP.getValue()) * 1.0e4;
                //double maxValue = ((Integer) maxSP.getValue()) * 1.0e4;
                double minValue = ((Integer) minSP.getValue());
                double maxValue = ((Integer) maxSP.getValue());
                recreateColorBarAndGradient(minValue, maxValue, "owi", wwd,
                        theSelectedComp.equalsIgnoreCase("owi"));
            }

            if (theRVLLimitChanged) {
                //SystemUtils.LOG.info("theRVLLimitChanged");

                //double minValue = ((Integer) minSP.getValue()) * 1.0e4;
                //double maxValue = ((Integer) maxSP.getValue()) * 1.0e4;

                double maxValue = ((Integer) maxRVLSP.getValue());
                double minValue = -1 * maxValue;

                recreateColorBarAndGradient(minValue, maxValue, "rvl", wwd,
                        theSelectedComp.equalsIgnoreCase("rvl"));
            }

            theOWILimitChanged = false;
            theRVLLimitChanged = false;
        }
    });
    theControlLevel2Panel.add(updateButton);

    createColorBarLegend(0, 10, "OWI Wind Speed", "owi");
    createColorBarLegend(0, 10, "OSW Wave Height.", "osw");
    createColorBarLegend(-6, 6, "RVL Rad. Vel.", "rvl");
    //addRenderable(theColorBarLegendHash.get("owi"));

    return theControlLevel2Panel;
}

From source file:org.jcurl.demo.tactics.BroomPromptSwingBean.java

public BroomPromptSwingBean() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    final Box b = Box.createVerticalBox();
    {//from  w ww .j av  a 2 s.c o  m
        final JPanel tb = new JPanel();
        tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));
        tb.setBorder(BorderFactory.createTitledBorder("Active"));
        tb.add(rock = new JComboBox(new Object[] { 1, 2, 3, 4, 5, 6, 7, 8 }));
        rock.setPrototypeDisplayValue(8);
        rock.addItemListener(this);
        dark = new JRadioButton("dark");
        dark.addActionListener(this);
        light = new JRadioButton("light");
        light.addActionListener(this);
        final ButtonGroup bg = new ButtonGroup();
        bg.add(dark);
        bg.add(light);
        tb.add(dark);
        tb.add(light);
        b.add(tb);
    }
    {
        final JPanel tb = new JPanel();
        tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));
        tb.setBorder(BorderFactory.createTitledBorder("Handle"));
        in = new JRadioButton("In Turn");
        in.addActionListener(this);
        out = new JRadioButton("Out Turn");
        out.addActionListener(this);
        final ButtonGroup bg = new ButtonGroup();
        bg.add(in);
        bg.add(out);
        tb.add(out);
        tb.add(in);
        tb.add(Box.createHorizontalGlue());
        b.add(tb);
    }
    {
        final JPanel tb = new JPanel();
        tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));
        tb.setBorder(BorderFactory.createTitledBorder("Split Time"));

        if (UseJSpinnerBoundedRange) {
            split2 = new JSpinnerBoundedRange();
            split2.addFocusListener(this);
            split = null;
        } else {
            split2 = null;
            split = new JSpinner();
            // log.info(split.getEditor().getClass().getName());
            split.addFocusListener(this);
            final JSpinner.NumberEditor ed = (JSpinner.NumberEditor) split.getEditor();
            ed.addFocusListener(this);
            ed.getTextField().addFocusListener(this);
        }

        tb.add(split2);

        tb.add(dt = new JComboBox(new Object[] { "1/1000 sec", "1/100 sec", "1/10 sec", "sec" }));
        tb.add(Box.createHorizontalGlue());
        b.add(tb);
        dt.setEnabled(false);
    }
    {
        final JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
        p.setBorder(BorderFactory.createTitledBorder("Broom Position"));
        {
            x = new JSpinnerNumberUnit();
            x.setLabel("x: ");
            x.setBase(Unit.METER);
            x.setChoose(Unit.FOOT, Unit.INCH, Unit.CENTIMETER, Unit.METER);
            x.setModel(new SpinnerNumberModel(0.0, -IceSize.SIDE_2_CENTER, IceSize.SIDE_2_CENTER, 0.1));
            x.addChangeListener(this);
            x.addPropertyChangeListener(this);
            p.add(x);
        }
        {
            y = new JSpinnerNumberUnit();
            y.setLabel("y: ");
            y.setBase(Unit.METER);
            y.setChoose(Unit.FOOT, Unit.INCH, Unit.CENTIMETER, Unit.METER);
            y.setModel(new SpinnerNumberModel(0.0, -IceSize.BACK_2_TEE, IceSize.HOG_2_TEE, 0.1));
            y.addChangeListener(this);
            y.addPropertyChangeListener(this);
            p.add(y);
        }
        b.add(p);
    }
    this.add(b);
}

From source file:org.jcurl.demo.tactics.CurlerSwingBean.java

public CurlerSwingBean() {
    setLayout(new BorderLayout());
    final Box b = Box.createVerticalBox();
    {//from w ww .j a  va  2  s  .co m
        final JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
        p.setBorder(BorderFactory.createTitledBorder("Curl Model"));
        p.add(curlers = new JComboBox(findCurlers()));
        b.add(p);
    }
    {
        final JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
        p.setBorder(BorderFactory.createTitledBorder("Draw-To-Tee"));
        {
            time = new JSpinnerNumberUnit();
            time.setLabel("time: ");
            time.setBase(Unit.SECOND);
            time.setModel(new SpinnerNumberModel(24.0, 17.0, 28.0, 0.1));
            time.addPropertyChangeListener(this);
            time.addChangeListener(this);
            p.add(time);
        }
        {
            curl = new JSpinnerNumberUnit();
            curl.setLabel("curl: ");
            curl.setBase(Unit.METER);
            curl.setChoose(Unit.FOOT, Unit.INCH, Unit.CENTIMETER, Unit.METER);
            curl.setModel(new SpinnerNumberModel(1.0, 0.0, 3.0, 0.1));
            curl.addPropertyChangeListener(this);
            curl.addChangeListener(this);
            p.add(curl);
        }
        b.add(p);
    }
    add(b, BorderLayout.NORTH);
    add(new JLabel("TODO: other settings"), BorderLayout.CENTER);
    setEnabled(false);
}

From source file:org.n52.ifgicopter.spf.input.FakeInputPlugin.java

/**
 * // ww w .j a  v  a2  s  .c  om
 * @return
 */
private JPanel makeControlPanel() {
    if (this.controlPanel == null) {
        this.controlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));

        JButton startButton = new JButton("Start");
        startButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        start();
                    }
                });
            }
        });
        this.controlPanel.add(startButton);
        JButton stopButton = new JButton("Stop");
        stopButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        stop();
                    }
                });
            }
        });
        this.controlPanel.add(stopButton);

        JLabel sleepTimeLabel = new JLabel("Time between points in seconds:");
        this.controlPanel.add(sleepTimeLabel);
        double spinnerMin = 0.1d;
        double spinnerMax = 10000.0d;
        SpinnerModel model = new SpinnerNumberModel(DEFAULT_INTERVAL_MILLIS / SECONDS_TO_MILLISECONDS,
                spinnerMin, spinnerMax, 0.1d);
        JSpinner sleepTimeSpinner = new JSpinner(model);
        sleepTimeSpinner.setToolTipText("Select time using controls or manual input within the range of "
                + spinnerMin + " to " + spinnerMax + ".");

        sleepTimeSpinner.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                Object source = e.getSource();
                if (source instanceof JSpinner) {
                    final JSpinner spinner = (JSpinner) source;

                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            Double value = (Double) spinner.getValue();
                            value = Double.valueOf(value.doubleValue() * SECONDS_TO_MILLISECONDS);
                            FakeInputPlugin.this.sleepTimeMillis = value.longValue();
                        }
                    });
                } else
                    log.warn("Unsupported ChangeEvent, need JSpinner as source: " + e);
            }
        });
        // catch text change events without loosing the focus
        // JSpinner.DefaultEditor editor = (DefaultEditor) sleepTimeSpinner.getEditor();
        // not implemented, can be done using KeyEvent, but then it hast to be checked where in the text
        // field the keystroke was etc. --> too complicated.

        this.controlPanel.add(sleepTimeSpinner);
    }

    return this.controlPanel;
}

From source file:org.n52.ifgicopter.spf.input.GpxInputPlugin.java

/**
 * @return/*  w  w w  .jav  a  2 s .co  m*/
 * 
 */
private JPanel makeControlPanel() {
    if (this.controlPanel == null) {
        this.controlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));

        JButton startButton = new JButton("Start");
        startButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        start();
                    }
                });
            }
        });
        this.controlPanel.add(startButton);
        JButton stopButton = new JButton("Stop");
        stopButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        stop();
                    }
                });
            }
        });
        this.controlPanel.add(stopButton);
        JButton selectFileButton = new JButton("Select GPX File");
        selectFileButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                selectGpxFileAction();
            }
        });
        this.controlPanel.add(selectFileButton);

        JLabel sleepTimeLabel = new JLabel("Time between points in seconds:");
        this.controlPanel.add(sleepTimeLabel);
        double spinnerMin = 0.5d;
        double spinnerMax = 10000.0d;
        SpinnerModel model = new SpinnerNumberModel(2.0d, spinnerMin, spinnerMax, 0.1d);
        JSpinner sleepTimeSpinner = new JSpinner(model);
        sleepTimeSpinner.setToolTipText("Select time using controls or manual input within the range of "
                + spinnerMin + " to " + spinnerMax + ".");

        sleepTimeSpinner.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                Object source = e.getSource();
                if (source instanceof JSpinner) {
                    final JSpinner spinner = (JSpinner) source;

                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            Double value = (Double) spinner.getValue();
                            value = Double.valueOf(value.doubleValue() * SECONDS_TO_MILLISECONDS);
                            setSleepTimeMillis(value.longValue());
                        }
                    });
                } else
                    getLog().warn("Unsupported ChangeEvent, need JSpinner as source: " + e);
            }
        });
        // catch text change events without loosing the focus
        // JSpinner.DefaultEditor editor = (DefaultEditor) sleepTimeSpinner.getEditor();
        // not implemented, can be done using KeyEvent, but then it hast to be checked where in the text
        // field the keystroke was etc. --> too complicated.

        this.controlPanel.add(sleepTimeSpinner);
    }

    return this.controlPanel;
}

From source file:org.n52.ifgicopter.spf.input.HistoryPostgisInputPlugin.java

/**
 * @return//from  w w  w . java 2 s.  c o m
 * 
 */
@Override
protected JPanel makeControlPanel() {
    if (this.controlPanel == null) {
        this.controlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));

        JButton startButton = new JButton("Start");
        startButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        start();
                    }
                });
            }
        });
        this.controlPanel.add(startButton);
        JButton stopButton = new JButton("Stop");
        stopButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        stop();
                    }
                });
            }
        });
        this.controlPanel.add(stopButton);

        JLabel sleepTimeLabel = new JLabel("Time between points in seconds:");
        this.controlPanel.add(sleepTimeLabel);
        double spinnerMin = 0.1d;
        double spinnerMax = 10000.0d;
        SpinnerModel model = new SpinnerNumberModel(2.0d, spinnerMin, spinnerMax, 0.1d);
        JSpinner sleepTimeSpinner = new JSpinner(model);
        sleepTimeSpinner.setToolTipText("Select time using controls or manual input within the range of "
                + spinnerMin + " to " + spinnerMax + ".");
        sleepTimeSpinner.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                Object source = e.getSource();
                if (source instanceof JSpinner) {
                    final JSpinner spinner = (JSpinner) source;

                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            Double value = (Double) spinner.getValue();
                            value = Double.valueOf(value.doubleValue() * 1000d);
                            setSleepTimeMillis(value.longValue());
                        }
                    });
                } else
                    log.warn("Unsupported ChangeEvent, need JSpinner as source: " + e);
            }
        });
        // catch text change events without loosing the focus
        // JSpinner.DefaultEditor editor = (DefaultEditor) sleepTimeSpinner.getEditor();
        // not implemented, can be done using KeyEvent, but then it hast to be checked where in the text
        // field the keystroke was etc. --> too complicated.

        this.controlPanel.add(sleepTimeSpinner);

        JLabel whereLabel = new JLabel("Where clause: ");
        this.whereField = new JTextField(this.where);
        this.whereField.setPreferredSize(new Dimension(200, 20));
        this.whereField.setToolTipText("Insert a valid SQL 'WHERE' clause here.");
        this.whereButton = new JButton("Load data");
        this.whereButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        updateWhere();

                        loadAllData();
                    }
                });
            }
        });

        this.controlPanel.add(whereLabel);
        this.controlPanel.add(this.whereField);
        this.controlPanel.add(this.whereButton);
    }

    return this.controlPanel;
}

From source file:org.n52.ifgicopter.spf.input.LastDataPostgisInputPlugin.java

@Override
protected JPanel makeControlPanel() {
    if (this.controlPanel == null) {
        this.controlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));

        JButton startButton = new JButton("Start");
        startButton.addActionListener(new ActionListener() {

            @Override//  www . j a v a  2  s.c o  m
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        start();
                    }
                });
            }
        });
        this.controlPanel.add(startButton);
        JButton stopButton = new JButton("Stop");
        stopButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        stop();
                    }
                });
            }
        });
        this.controlPanel.add(stopButton);

        JLabel minTimeLabel = new JLabel("Mimium time database queries in milliseconds:");
        this.controlPanel.add(minTimeLabel);
        SpinnerModel model = new SpinnerNumberModel(this.minimumMillisBetweenRequests, 10d, 3600000d, 10d);
        JSpinner sleepTimeSpinner = new JSpinner(model);
        sleepTimeSpinner.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                Object source = e.getSource();
                if (source instanceof JSpinner) {
                    final JSpinner spinner = (JSpinner) source;

                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            Double value = (Double) spinner.getValue();
                            value = Double.valueOf(value.doubleValue() * 1000d);
                            setMinimumMillisBetweenRequests(value.longValue());
                        }
                    });
                } else
                    log.warn("Unsupported ChangeEvent, need JSpinner as source: " + e);
            }
        });
        // catch text change events without loosing the focus
        // JSpinner.DefaultEditor editor = (DefaultEditor) sleepTimeSpinner.getEditor();
        // not implemented, can be done using KeyEvent, but then it hast to be checked where in the text
        // field the keystroke was etc. --> too complicated.

        this.controlPanel.add(sleepTimeSpinner);
    }

    return this.controlPanel;
}

From source file:org.pentaho.reporting.ui.datasources.jdbc.ui.JdbcDataSourceDialog.java

/**
 * Creates the panel which holds the main content of the dialog
 *//*from   w  w w.  j  av  a2s .  com*/
private void initDialog(final DesignTimeContext designTimeContext) {
    this.designTimeContext = designTimeContext;

    setTitle(Messages.getString("JdbcDataSourceDialog.Title"));
    setModal(true);

    globalTemplateAction = new GlobalTemplateAction();
    queryTemplateAction = new QueryTemplateAction();

    dialogModel = new NamedDataSourceDialogModel();
    dialogModel.addPropertyChangeListener(new ConfirmValidationHandler());

    connectionComponent = new JdbcConnectionPanel(dialogModel, designTimeContext);
    maxPreviewRowsSpinner = new JSpinner(new SpinnerNumberModel(10000, 1, Integer.MAX_VALUE, 1));

    final QueryNameTextFieldDocumentListener updateHandler = new QueryNameTextFieldDocumentListener();
    dialogModel.getQueries().addListDataListener(updateHandler);

    queryNameList = new JList(dialogModel.getQueries());
    queryNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    queryNameList.setVisibleRowCount(5);
    queryNameList.addListSelectionListener(new QuerySelectedHandler());

    queryNameTextField = new JTextField();
    queryNameTextField.setColumns(35);
    queryNameTextField.setEnabled(dialogModel.isQuerySelected());
    queryNameTextField.getDocument().addDocumentListener(updateHandler);

    queryTextArea = new RSyntaxTextArea();
    queryTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
    queryTextArea.setEnabled(dialogModel.isQuerySelected());
    queryTextArea.getDocument().addDocumentListener(new QueryDocumentListener());

    globalScriptTextArea = new RSyntaxTextArea();
    globalScriptTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);

    globalLanguageField = new SmartComboBox<ScriptEngineFactory>(
            new DefaultComboBoxModel(DataFactoryEditorSupport.getScriptEngineLanguages()));
    globalLanguageField.setRenderer(new QueryLanguageListCellRenderer());
    globalLanguageField.addActionListener(new UpdateScriptLanguageHandler());

    queryScriptTextArea = new RSyntaxTextArea();
    queryScriptTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
    queryScriptTextArea.getDocument().addDocumentListener(new QueryScriptDocumentListener());

    queryLanguageListCellRenderer = new QueryLanguageListCellRenderer();

    queryLanguageField = new SmartComboBox<ScriptEngineFactory>(
            new DefaultComboBoxModel(DataFactoryEditorSupport.getScriptEngineLanguages()));
    queryLanguageField.setRenderer(queryLanguageListCellRenderer);
    queryLanguageField.addActionListener(new UpdateScriptLanguageHandler());

    super.init();
}

From source file:org.pentaho.reporting.ui.datasources.mondrian.MondrianDataSourceEditor.java

protected void init(final DesignTimeContext context) {
    if (context == null) {
        throw new NullPointerException();
    }//  ww w . ja  v a  2 s . c  om

    securityDialog = new MondrianSecurityDialog(this, context);

    setModal(true);

    this.context = context;

    globalTemplateAction = new GlobalTemplateAction();
    queryTemplateAction = new QueryTemplateAction();

    final QueryNameTextFieldDocumentListener updateHandler = new QueryNameTextFieldDocumentListener();
    final ConfirmEnableHandler confirmAction = new ConfirmEnableHandler();

    dialogModel = new NamedDataSourceDialogModel();
    dialogModel.getQueries().addListDataListener(updateHandler);
    dialogModel.addPropertyChangeListener(confirmAction);

    maxPreviewRowsSpinner = new JSpinner(new SpinnerNumberModel(10000, 1, Integer.MAX_VALUE, 1));

    cubeConnectionNameField = new JTextField(null, 0);
    cubeConnectionNameField.setColumns(30);
    cubeConnectionNameField.getDocument().addDocumentListener(confirmAction);

    filenameField = new JTextField(null, 0);
    filenameField.setColumns(30);
    filenameField.getDocument().addDocumentListener(confirmAction);
    dialogModel.setSchemaFileNameField(filenameField);

    queryNameTextField = new JTextField(null, 0);
    queryNameTextField.setColumns(35);
    queryNameTextField.setEnabled(dialogModel.isQuerySelected());
    queryNameTextField.getDocument().addDocumentListener(updateHandler);

    queryTextArea = new JTextArea((String) null);
    queryTextArea.setWrapStyleWord(true);
    queryTextArea.setLineWrap(true);
    queryTextArea.setRows(5);
    queryTextArea.getDocument().addDocumentListener(new QueryDocumentListener());

    queryNameList = new JList(getDialogModel().getQueries());
    queryNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    queryNameList.setVisibleRowCount(5);
    queryNameList.addListSelectionListener(new QuerySelectedHandler());

    globalScriptTextArea = new RSyntaxTextArea();
    globalScriptTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);

    globalLanguageField = new SmartComboBox<ScriptEngineFactory>(
            new DefaultComboBoxModel(DataFactoryEditorSupport.getScriptEngineLanguages()));
    globalLanguageField.setRenderer(new QueryLanguageListCellRenderer());
    globalLanguageField.addActionListener(new UpdateScriptLanguageHandler());

    queryScriptTextArea = new RSyntaxTextArea();
    queryScriptTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
    queryScriptTextArea.getDocument().addDocumentListener(new QueryScriptDocumentListener());

    queryLanguageListCellRenderer = new QueryLanguageListCellRenderer();

    queryLanguageField = new SmartComboBox<ScriptEngineFactory>(
            new DefaultComboBoxModel(DataFactoryEditorSupport.getScriptEngineLanguages()));
    queryLanguageField.setRenderer(queryLanguageListCellRenderer);
    queryLanguageField.addActionListener(new UpdateScriptLanguageHandler());

    // Return the center panel
    super.init();
}

From source file:org.pentaho.reporting.ui.datasources.olap4j.Olap4JDataSourceEditor.java

protected void init(final DesignTimeContext designTimeContext) {
    setModal(true);/*  w  w  w  .j av a2s.com*/

    this.context = designTimeContext;

    final QueryNameTextFieldDocumentListener updateHandler = new QueryNameTextFieldDocumentListener();

    globalTemplateAction = new GlobalTemplateAction();
    queryTemplateAction = new QueryTemplateAction();

    dialogModel = new NamedDataSourceDialogModel(
            new JdbcConnectionDefinitionManager("org/pentaho/reporting/ui/datasources/olap4j/Settings"));
    dialogModel.addPropertyChangeListener(NamedDataSourceDialogModel.CONNECTION_SELECTED,
            new ConfirmEnableHandler());
    dialogModel.getQueries().addListDataListener(updateHandler);

    connectionComponent = new OlapConnectionPanel(dialogModel, designTimeContext);
    connectionComponent.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));

    maxPreviewRowsSpinner = new JSpinner(new SpinnerNumberModel(10000, 1, Integer.MAX_VALUE, 1));

    queryNameTextField = new JTextField();
    queryNameTextField.setColumns(35);
    queryNameTextField.setEnabled(dialogModel.isQuerySelected());
    queryNameTextField.getDocument().addDocumentListener(updateHandler);

    queryTextArea = new JTextArea((String) null);
    queryTextArea.setWrapStyleWord(true);
    queryTextArea.setLineWrap(true);
    queryTextArea.setRows(10);
    queryTextArea.setColumns(50);
    queryTextArea.setEnabled(dialogModel.isQuerySelected());
    queryTextArea.getDocument().addDocumentListener(new QueryDocumentListener());

    queryNameList = new JList(dialogModel.getQueries());
    queryNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    queryNameList.setVisibleRowCount(5);
    queryNameList.addListSelectionListener(new QuerySelectedHandler());

    globalScriptTextArea = new RSyntaxTextArea();
    globalScriptTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);

    globalLanguageField = new SmartComboBox<ScriptEngineFactory>(
            new DefaultComboBoxModel(DataFactoryEditorSupport.getScriptEngineLanguages()));
    globalLanguageField.setRenderer(new QueryLanguageListCellRenderer());
    globalLanguageField.addActionListener(new UpdateScriptLanguageHandler());

    queryScriptTextArea = new RSyntaxTextArea();
    queryScriptTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
    queryScriptTextArea.getDocument().addDocumentListener(new QueryScriptDocumentListener());

    queryLanguageListCellRenderer = new QueryLanguageListCellRenderer();

    queryLanguageField = new SmartComboBox<ScriptEngineFactory>(
            new DefaultComboBoxModel(DataFactoryEditorSupport.getScriptEngineLanguages()));
    queryLanguageField.setRenderer(queryLanguageListCellRenderer);
    queryLanguageField.addActionListener(new UpdateScriptLanguageHandler());

    super.init();
    // Return the center panel
}