List of usage examples for javax.swing AbstractButton getModel
public ButtonModel getModel()
From source file:SciTK.PlotXYZBlock.java
private void init(String x_label, String y_label, String window_title) { chart = ChartFactory.createScatterPlot("", x_label, y_label, data, PlotOrientation.VERTICAL, false, true, false);/*from w ww.j a va 2 s. c o m*/ // turn off borders of the plot: XYPlot p = chart.getXYPlot(); p.getDomainAxis().setLowerMargin(0.0); p.getDomainAxis().setUpperMargin(0.0); p.getRangeAxis().setLowerMargin(0.0); p.getRangeAxis().setUpperMargin(0.0); // -------------------------------------------- // set up a lookup table // -------------------------------------------- // this is how we render the block plots: XYBlockRenderer renderer = new XYBlockRenderer(); // need to find max and min z of the data set: double min = 0; double max = 0; for (int i = 0; i < data.getSeriesCount(); i++) // iterate over data sets { for (int j = 0; j < data.getItemCount(i); j++) // iterate over points in dataset { if (data.getZValue(i, j) < min) min = data.getZValue(i, j); else if (data.getZValue(i, j) > max) max = data.getZValue(i, j); } } // create paint scale using min and max values, default color black: LookupPaintScale paintScale = new LookupPaintScale(min, max, Color.black); // set up the LUT: double step_size = (max - min) / 255.; // step size for LUT for (int i = 0; i < 256; i++) { paintScale.add(min + i * step_size, new Color(i, i, i, 255)); } renderer.setPaintScale(paintScale); // set this renderer to the plot: p.setRenderer(renderer); // -------------------------------------------- // set up a color bar // -------------------------------------------- // create an array of display labels: num_labels = 10; // default to 10 labels on color bar double display_step_size = (max - min) / ((double) num_labels); String[] scale_bar_labels = new String[num_labels + 1]; // to format numbers in scientific notation: DecimalFormat formater = new DecimalFormat("0.#E0"); // create list of labesl: for (int i = 0; i <= num_labels; i++) { scale_bar_labels[i] = formater.format(min + i * display_step_size); } // create axis: SymbolAxis scaleAxis = new SymbolAxis(null, scale_bar_labels); scaleAxis.setRange(min, max); scaleAxis.setPlot(new PiePlot()); scaleAxis.setGridBandsVisible(false); // set up the paint scale: psl = new PaintScaleLegend(paintScale, scaleAxis); psl.setBackgroundPaint(new Color(255, 255, 255, 0)); // clear background // set up frame with buffer region to allow text display psl.setFrame(new LineBorder((Paint) Color.BLACK, new BasicStroke((float) 1.0), new RectangleInsets(15, 10, 15, 10))); psl.setAxisOffset(5.0); // display on right side: psl.setPosition(RectangleEdge.RIGHT); // margin around color scale: psl.setMargin(new RectangleInsets(20, 15, 20, 15)); // add to the chart so it will be displayed by default: chart.addSubtitle(psl); // -------------------------------------------- // WINDOW-RELATED UI // -------------------------------------------- // set up the generic plot UI: super.window_title = window_title; super.initUI(); // add another menu item JMenuBar mb = super.getJMenuBar(); // get the menu bar // find menu named "Plot" JMenu menu_plot = null; for (int i = 0; i < mb.getMenuCount(); i++) { if (mb.getMenu(i).getText() == "Plot") menu_plot = mb.getMenu(i); } // Add a new checkbox for the color scale bar JCheckBoxMenuItem menu_plot_scalebar = new JCheckBoxMenuItem("Color Scale"); menu_plot_scalebar.setToolTipText("Show color scale bar?"); menu_plot_scalebar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setScaleBar(selected); } }); // set appropirate checkbox state: menu_plot_scalebar.setState(true); if (menu_plot != null) // sanity check menu_plot.add(menu_plot_scalebar); }
From source file:com.codeasylum.liquibase.Liquidate.java
public synchronized void setConfig(LiquidateConfig config) { this.config = config; changeSensitive = false;//from w w w . ja va2 s .com try { databaseCombo.setSelectedItem((config.getDatabase() == null) ? Database.MYSQL : config.getDatabase()); hostTextField.setText((config.getHost() == null) ? "" : config.getHost()); portTextField.setText((config.getPort() == 0) ? "" : String.valueOf(config.getPort())); schemaTextField.setText((config.getSchema() == null) ? "" : config.getSchema()); userTextField.setText((config.getUser() == null) ? "" : config.getUser()); passwordField.setText((config.getPassword() == null) ? "" : config.getPassword()); for (AbstractButton button : new EnumerationIterator<AbstractButton>(sourceButtonGroup.getElements())) { if (button.getActionCommand() .equals((config.getSource() == null) ? Source.FILE.name() : config.getSource().name())) { sourceButtonGroup.setSelected(button.getModel(), true); break; } } changeLogTextField.setText((config.getChangeLog() == null) ? "" : config.getChangeLog()); for (AbstractButton button : new EnumerationIterator<AbstractButton>(goalButtonGroup.getElements())) { if (button.getActionCommand() .equals((config.getGoal() == null) ? Goal.PREVIEW.name() : config.getGoal().name())) { goalButtonGroup.setSelected(button.getModel(), true); break; } } outputTextField.setText(config.getOutput()); outputTextField .setEnabled(config.getGoal().equals(Goal.GENERATE) || config.getGoal().equals(Goal.DOCUMENT)); browseButton .setEnabled(config.getGoal().equals(Goal.GENERATE) || config.getGoal().equals(Goal.DOCUMENT)); } finally { changeSensitive = true; } }
From source file:ca.sqlpower.wabit.swingui.chart.ChartPanel.java
private ChartType getSelectedChartType() { for (Enumeration<AbstractButton> buttons = chartTypeButtonGroup.getElements(); buttons.hasMoreElements();) { AbstractButton b = buttons.nextElement(); if (chartTypeButtonGroup.isSelected(b.getModel())) { ChartType ct = (ChartType) b.getClientProperty(CHART_TYPE_PROP_KEY); logger.debug("Found selected chart type " + ct); return ct; }//from w ww . j av a 2 s. c om } logger.debug("Didn't find any selected chart buttons. Returning null."); return null; }
From source file:ca.sqlpower.wabit.swingui.chart.ChartPanel.java
/** * Selects the appropriate button in {@link #chartTypeButtonGroup}. * //from w w w. j av a 2 s . com * @param type The type of chart to select the button of. */ private void setSelectedChartType(ChartType type) { for (Enumeration<AbstractButton> buttons = chartTypeButtonGroup.getElements(); buttons.hasMoreElements();) { AbstractButton b = buttons.nextElement(); ChartType ct = (ChartType) b.getClientProperty(CHART_TYPE_PROP_KEY); if (ct == type) { chartTypeButtonGroup.setSelected(b.getModel(), true); return; } } throw new IllegalArgumentException("I can't find a button for chart type " + type); }
From source file:temp1.JFrame1.java
private void jToggleButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton4ActionPerformed AbstractButton abstractButton = (AbstractButton) evt.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (!selected) c1 = selected;/* w w w. ja va 2 s .com*/ if (selected) c1 = selected; }
From source file:temp1.JFrame1.java
private void jToggleButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton5ActionPerformed AbstractButton abstractButton = (AbstractButton) evt.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (!selected) c2 = selected;/*from w ww.j av a 2s.co m*/ if (selected) c2 = selected; }
From source file:temp1.JFrame1.java
private void jToggleButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton6ActionPerformed AbstractButton abstractButton = (AbstractButton) evt.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (!selected) c3 = selected;/*from w ww.j ava2 s. c o m*/ if (selected) c3 = selected; }
From source file:temp1.JFrame1.java
private void jToggleButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton7ActionPerformed AbstractButton abstractButton = (AbstractButton) evt.getSource(); boolean selected = abstractButton.getModel().isSelected(); if (!selected) c4 = selected;/*from ww w . ja v a2s .co m*/ if (selected) c4 = selected; }
From source file:SciTK.Plot.java
/** * Load the initial UI/*from w ww .j av a 2 s.c o m*/ */ protected final void initUI() { setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); // create a ChartPanel, and make it default to 1/4 of screen size: chart_panel = new ChartPanel(chart); chart_panel.setPreferredSize(new Dimension(def_width, def_height)); //add the chart to the window: getContentPane().add(chart_panel); // create a menu bar: menubar = new JMenuBar(); // --------------------------------------------------------- // First dropdown menu: "File" // --------------------------------------------------------- file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); // Set up a save dialog option under the file menu: JMenuItem menu_file_save; ImageIcon menu_file_save_icon = null; try { menu_file_save_icon = new ImageIcon(getClass().getResource("/SciTK/resources/document-save-5.png")); menu_file_save = new JMenuItem("Save", menu_file_save_icon); } catch (Exception e) { menu_file_save = new JMenuItem("Save"); } menu_file_save.setMnemonic(KeyEvent.VK_S); menu_file_save.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu_file_save.setToolTipText("Save an image"); menu_file_save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveImage(); } }); file.add(menu_file_save); // Set up a save SVG dialog option under the file menu: JMenuItem menu_file_save_svg; try { menu_file_save_svg = new JMenuItem("Save VG", menu_file_save_icon); } catch (Exception e) { menu_file_save_svg = new JMenuItem("Save VG"); } menu_file_save_svg.setToolTipText("Save as vector graphics (SVG,PS,EPS)"); menu_file_save_svg.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveVectorGraphics(); } }); file.add(menu_file_save_svg); // Set up a save data dialog option under the file menu: JMenuItem menu_file_save_data; try { menu_file_save_data = new JMenuItem("Save data", menu_file_save_icon); } catch (Exception e) { menu_file_save_data = new JMenuItem("Save data"); } menu_file_save_data.setToolTipText("Save raw data to file"); menu_file_save_data.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveData(); } }); file.add(menu_file_save_data); // Set up a save data dialog option under the file menu: JMenuItem menu_file_print; try { ImageIcon menu_file_print_icon = new ImageIcon( getClass().getResource("/SciTK/resources/document-print-5.png")); menu_file_print = new JMenuItem("Print", menu_file_print_icon); } catch (Exception e) { menu_file_print = new JMenuItem("Print"); } menu_file_print.setToolTipText("Print image of chart"); menu_file_print.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { printPlot(); } }); file.add(menu_file_print); // menu item for exiting JMenuItem menu_file_exit; try { ImageIcon menu_file_exit_icon = new ImageIcon( getClass().getResource("/SciTK/resources/application-exit.png")); menu_file_exit = new JMenuItem("Exit", menu_file_exit_icon); } catch (Exception e) { menu_file_exit = new JMenuItem("Exit"); } menu_file_exit.setMnemonic(KeyEvent.VK_X); menu_file_exit.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu_file_exit.setToolTipText("Exit application"); menu_file_exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dispose(); } }); file.add(menu_file_exit); // --------------------------------------------------------- // Second dropdown menu: "Edit" // --------------------------------------------------------- edit = new JMenu("Edit"); edit.setMnemonic(KeyEvent.VK_E); // copy to clipboard JMenuItem menu_edit_copy_image; ImageIcon menu_edit_copy_icon = null; try { menu_edit_copy_icon = new ImageIcon(getClass().getResource("/SciTK/resources/edit-copy-7.png")); menu_edit_copy_image = new JMenuItem("Copy", menu_edit_copy_icon); } catch (Exception e) { menu_edit_copy_image = new JMenuItem("Copy"); } menu_edit_copy_image.setMnemonic(KeyEvent.VK_C); menu_edit_copy_image.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu_edit_copy_image.setToolTipText("Copy image to clipboard"); menu_edit_copy_image.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { copyImage(); } }); edit.add(menu_edit_copy_image); // copy data to clipboard JMenuItem menu_edit_copy_data; try { menu_edit_copy_data = new JMenuItem("Copy data", menu_edit_copy_icon); } catch (Exception e) { menu_edit_copy_data = new JMenuItem("Copy data"); } menu_edit_copy_data.setToolTipText("Copy data to clipboard"); menu_edit_copy_data.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { copyData(); } }); edit.add(menu_edit_copy_data); // set background color JMenuItem menu_edit_BackgroundColor; ImageIcon menu_edit_Color_icon = null; try { menu_edit_Color_icon = new ImageIcon(getClass().getResource("/SciTK/resources/color-wheel.png")); menu_edit_BackgroundColor = new JMenuItem("Background Color", menu_edit_Color_icon); } catch (Exception e) { menu_edit_BackgroundColor = new JMenuItem("Background Color"); } menu_edit_BackgroundColor.setToolTipText("Select background color"); menu_edit_BackgroundColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Color bgColor = plotColorChooser("Choose background color", (Color) chart.getBackgroundPaint()); setBackgroundColor(bgColor); } }); edit.add(menu_edit_BackgroundColor); // set plot color JMenuItem menu_edit_PlotColor; try { menu_edit_PlotColor = new JMenuItem("Window Color", menu_edit_Color_icon); } catch (Exception e) { menu_edit_PlotColor = new JMenuItem("Window Color"); } menu_edit_PlotColor.setToolTipText("Select plot window color"); menu_edit_PlotColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Color plotColor = plotColorChooser("Choose plot color", (Color) chart.getPlot().getBackgroundPaint()); setWindowBackground(plotColor); } }); edit.add(menu_edit_PlotColor); // set gridline color JMenuItem menu_edit_GridlineColor; try { menu_edit_GridlineColor = new JMenuItem("Gridline Color", menu_edit_Color_icon); } catch (Exception e) { menu_edit_GridlineColor = new JMenuItem("Gridline Color"); } menu_edit_GridlineColor.setToolTipText("Select grid color"); menu_edit_GridlineColor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Color gridColor = plotColorChooser("Choose grid color", (Color) chart.getPlot().getBackgroundPaint()); setGridlineColor(gridColor); } }); edit.add(menu_edit_GridlineColor); // edit chart preferences JMenuItem menu_edit_preferences; try { ImageIcon menu_edit_preferences_icon = new ImageIcon( getClass().getResource("/SciTK/resources/preferences-desktop-3.png")); menu_edit_preferences = new JMenuItem("Preferences", menu_edit_preferences_icon); } catch (Exception e) { menu_edit_preferences = new JMenuItem("Preferences"); } menu_edit_preferences.setToolTipText("Edit chart preferences"); menu_edit_preferences.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { chart_panel.doEditChartProperties(); } }); edit.add(menu_edit_preferences); // --------------------------------------------------------- // Third dropdown menu: "Plot" // --------------------------------------------------------- plot = new JMenu("Plot"); plot.setMnemonic(KeyEvent.VK_P); // Options to set log axes JCheckBoxMenuItem menu_plot_ylog = new JCheckBoxMenuItem("Log y axis"); menu_plot_ylog.setToolTipText("Set y axis to logarithmic"); menu_plot_ylog.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setRangeAxisLog(selected); } }); plot.add(menu_plot_ylog); JCheckBoxMenuItem menu_plot_xlog = new JCheckBoxMenuItem("Log x axis"); menu_plot_xlog.setToolTipText("Set x axis to logarithmic"); menu_plot_xlog.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setDomainAxisLog(selected); } }); plot.add(menu_plot_xlog); // grid line display JCheckBoxMenuItem menu_plot_grid = new JCheckBoxMenuItem("Grid lines"); menu_plot_grid.setToolTipText("Show plot grid lines?"); menu_plot_grid.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setGridlineVisible(selected); } }); // set appropirate checkbox state: menu_plot_grid.setState(chart.getXYPlot().isDomainGridlinesVisible()); plot.add(menu_plot_grid); // control for displaying plot legend JCheckBoxMenuItem menu_plot_legend = new JCheckBoxMenuItem("Legend"); menu_plot_legend.setToolTipText("Show plot legend?"); menu_plot_legend.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); setLegend(selected); } }); // set appropirate checkbox state: menu_plot_legend.setState((chart.getLegend() instanceof LegendTitle)); plot.add(menu_plot_legend); // --------------------------------------------------------- // General UI // --------------------------------------------------------- // Add menus to the menu bar: menubar.add(file); menubar.add(edit); menubar.add(plot); // Set menubar as this JFrame's menu setJMenuBar(menubar); // set default plot colors: chart.setBackgroundPaint(new Color(255, 255, 255, 0)); chart.getPlot().setBackgroundPaint(new Color(255, 255, 255, 255)); setBackgroundAlpha(0.0f); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); pack(); setTitle(window_title); setLocationRelativeTo(null); setVisible(true); }
From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java
private void initUI() { setLayout(new GridBagLayout()); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); components = new ArrayList<JComponent>(); checks = new ArrayList<JCheckBox>(); int size = paramList.size(); boolean shouldExpand = false; boolean needScroll = false; for (int i = 0; i < size; i++) { final int pos = i; final QueryParameter param = paramList.get(i); if (param.isHidden()) { components.add(null);/*from w w w . ja va2s .co m*/ checks.add(null); initHiddenParameterValues(param); continue; } String source = param.getSource(); String defaultSource = param.getDefaultSource(); if ((defaultSource != null) && !defaultSource.trim().equals("")) { try { param.setDefaultSourceValues(Globals.getDBViewer().getDefaultSourceValues(con, param)); } catch (NextSqlException e) { Show.error(e); } } final JComponent component; int anchor = GridBagConstraints.WEST; double y = 0.0; int expand = GridBagConstraints.HORIZONTAL; if ((source != null) && !source.equals("")) { List<IdName> values = new ArrayList<IdName>(); try { if (param.isManualSource()) { if (!param.isDependent()) { values = Globals.getDBViewer().getValues(con, source, true, param.getOrderBy()); } } else { int index = source.indexOf("."); int index2 = source.lastIndexOf("."); String tableName = source.substring(0, index); String columnName; String shownColumnName = null; if (index == index2) { columnName = source.substring(index + 1); } else { columnName = source.substring(index + 1, index2); shownColumnName = source.substring(index2 + 1); } values = Globals.getDBViewer().getColumnValues(con, param.getSchema(), tableName, columnName, shownColumnName, param.getOrderBy()); } } catch (NextSqlException e) { error = true; Show.error(e); } catch (InvalidSqlException e) { String m = I18NSupport.getString("source.dialog.valid"); Show.info(m + " : \"select <exp1> , <exp2> from ...\""); } if (param.getSelection().equals(ParameterEditPanel.SINGLE_SELECTION)) { component = new JComboBox(); final JComboBox combo = (JComboBox) component; combo.setRenderer(new IdNameRenderer()); combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --"); for (int j = 0, len = values.size(); j < len; j++) { combo.addItem(values.get(j)); } combo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { IdName in = null; if (combo.getSelectedIndex() > 0) { in = (IdName) combo.getSelectedItem(); } parameterSelection(pos, in); } } }); AutoCompleteDecorator.decorate(combo); needScroll = false; } else { anchor = GridBagConstraints.NORTHWEST; y = 1.0; expand = GridBagConstraints.BOTH; DefaultListModel model = new DefaultListModel(); for (int j = 0, len = values.size(); j < len; j++) { model.addElement(values.get(j)); } List srcList = Arrays.asList(model.toArray()); component = new ListSelectionPanel(srcList, new ArrayList(), "", "", true, false) { protected void onAdd() { selection(); } protected void onRemove() { selection(); } // needed for saved parameters on rerun protected void onSetRight() { selection(); } private void selection() { if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) { Object[] values = getDestinationElements().toArray(); if (values.length == 0) { values = new Object[] { ParameterUtil.NULL }; } parameterSelection(pos, values); } } }; ((ListSelectionPanel) component).setListSize(scrListDim); ((ListSelectionPanel) component).setRenderer(new IdNameRenderer(), new IdNameComparator(param.getOrderBy())); shouldExpand = true; } } else { if (param.getSelection().equals(QueryParameter.MULTIPLE_SELECTION)) { anchor = GridBagConstraints.NORTHWEST; y = 1.0; expand = GridBagConstraints.BOTH; ; component = new ListAddPanel(param) { protected void onAdd() { selection(); } protected void onRemove() { selection(); } private void selection() { if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) { Object[] values = getElements().toArray(); parameterSelection(pos, values); } } }; } else { needScroll = false; if (param.getValueClassName().equals("java.util.Date")) { component = new JXDatePicker(); ((JXDatePicker) component).addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("date".equals(e.getPropertyName())) { parameterSelection(pos, ((JXDatePicker) component).getDate()); } } }); // hack to fix bug with big popup button JButton popupButton = (JButton) component.getComponent(1); //popupButton.setMargin(new Insets(2, 2, 2, 2)); popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY)); } else if (param.getValueClassName().equals("java.sql.Timestamp") || param.getValueClassName().equals("java.sql.Time")) { component = new JDateTimePicker() { protected void onChange() { parameterSelection(pos, getDate()); } }; // hack to fix bug with big popup button JButton popupButton = (JButton) (((JDateTimePicker) component).getDatePicker()) .getComponent(1); //popupButton.setMargin(new Insets(2, 2, 2, 2)); popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight())); popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY)); } else if (param.getValueClassName().equals("java.lang.Boolean")) { component = new JCheckBox(); ((JCheckBox) component).addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { AbstractButton abstractButton = (AbstractButton) actionEvent.getSource(); boolean selected = abstractButton.getModel().isSelected(); parameterSelection(pos, selected); } }); } else { component = new JTextField(25); ((JTextField) component).getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { updateFromTextField(e); } @Override public void insertUpdate(DocumentEvent e) { updateFromTextField(e); } @Override public void removeUpdate(DocumentEvent e) { updateFromTextField(e); } private void updateFromTextField(DocumentEvent e) { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { Object value = null; try { if ("".equals(((JTextField) component).getText().trim())) { value = null; } else { value = ParameterUtil.getParameterValueFromString( param.getValueClassName(), ((JTextField) component).getText()); } parameterSelection(pos, value); } catch (Exception e) { e.printStackTrace(); LOG.error(e.getMessage(), e); } } }); } }); } } } components.add(component); final JCheckBox cb = new JCheckBox(I18NSupport.getString("run.parameter.ignore")); checks.add(cb); final JLabel label = new JLabel(getRuntimeParameterName(param)); panel.add(label, new GridBagConstraints(0, i, 1, 1, 0.0, 0.0, anchor, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); final JComponent addComponent; if (needScroll) { JScrollPane scr = new JScrollPane(component, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scr.setPreferredSize(listDim); addComponent = scr; } else { addComponent = component; } panel.add(addComponent, new GridBagConstraints(1, i, 1, 1, 1.0, y, GridBagConstraints.WEST, expand, new Insets(5, 0, 5, 5), 0, 0)); int checkAnchor = GridBagConstraints.WEST; if ((addComponent instanceof JScrollPane) || (addComponent instanceof ListSelectionPanel)) { checkAnchor = GridBagConstraints.NORTHWEST; } if (Globals.getParametersIgnore()) { panel.add(cb, new GridBagConstraints(2, i, 1, 1, 0.0, 0.0, checkAnchor, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); } cb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (cb.isSelected()) { if (addComponent instanceof JScrollPane) { component.setEnabled(false); } label.setEnabled(false); addComponent.setEnabled(false); param.setIgnore(true); } else { if (addComponent instanceof JScrollPane) { component.setEnabled(true); } label.setEnabled(true); addComponent.setEnabled(true); param.setIgnore(false); } } }); } // populate hidden dependent parameters (this will be done if a parameter depends only on a single hidden parameter) // if a parameter depends on a hidden parameter and other parameters, it cannot be populated here for (int i = 0; i < size; i++) { final QueryParameter param = paramList.get(i); if (param.isHidden()) { populateDependentParameters(param, false); } } if (!shouldExpand) { panel.add(new JLabel(), new GridBagConstraints(0, size, 3, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); } JScrollPane scrPanel = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrPanel.setPreferredSize(scrDim); scrPanel.setMinimumSize(scrDim); add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); setParameterValues(parametersValues); setParameterIgnore(parametersIgnore); }