List of usage examples for java.awt.event ItemListener ItemListener
ItemListener
From source file:CheckBoxNodeTreeSample.java
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row) { Component editor = renderer.getTreeCellRendererComponent(tree, value, true, expanded, leaf, row, true); // editor always selected / focused ItemListener itemListener = new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { if (stopCellEditing()) { fireEditingStopped();/*from w ww .j a va 2 s. c o m*/ } } }; if (editor instanceof JCheckBox) { ((JCheckBox) editor).addItemListener(itemListener); } return editor; }
From source file:org.metacsp.utility.UI.SearchTreeFrame.java
public SearchTreeFrame(DelegateForest<MetaVariable, ConstraintNetwork> graph) { this.graph = graph; treeLayout = new TreeLayout<MetaVariable, ConstraintNetwork>(graph); radialLayout = new RadialTreeLayout<MetaVariable, ConstraintNetwork>(graph); radialLayout.setSize(new Dimension(600, 600)); vv = new VisualizationViewer<MetaVariable, ConstraintNetwork>(treeLayout, new Dimension(600, 600)); vv.setBackground(Color.white); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<MetaVariable, ConstraintNetwork>()); vv.getRenderContext().setVertexLabelTransformer(new Transformer<MetaVariable, String>() { @Override//from w ww. ja v a 2 s .c o m public String transform(MetaVariable arg0) { return arg0.toString(); } }); vv.setVertexToolTipTransformer(new Transformer<MetaVariable, String>() { @Override public String transform(MetaVariable arg0) { return arg0.toString(); } }); //vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray)); vv.getRenderContext().setArrowFillPaintTransformer(new Transformer<ConstraintNetwork, Paint>() { @Override public Paint transform(ConstraintNetwork arg0) { return Color.lightGray; } }); //System.out.println(graph.getVertices()); rings = new Rings(); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse<?, ?> graphMouse = new DefaultModalGraphMouse<Object, Object>(); vv.setGraphMouse(graphMouse); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.addItemListener(graphMouse.getModeListener()); graphMouse.setMode(Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JToggleButton radial = new JToggleButton("Radial"); radial.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<MetaVariable, ConstraintNetwork> lt = new LayoutTransition<MetaVariable, ConstraintNetwork>( vv, treeLayout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<MetaVariable, ConstraintNetwork> lt = new LayoutTransition<MetaVariable, ConstraintNetwork>( vv, radialLayout, treeLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); controls.add(modeBox); content.add(controls, BorderLayout.SOUTH); }
From source file:de.codesourcery.eve.skills.ui.components.impl.PriceHistoryComponent.java
@Override protected JPanel createPanel() { dateRangeChooser.setModel(new DefaultComboBoxModel<DisplayRange>(Arrays.asList(DisplayRange.values()))); dateRangeChooser.setSelectedItem(DisplayRange.WEEK); final JPanel controlPanel = new JPanel(); controlPanel.setBackground(Color.WHITE); // controlPanel.setLayout( new GridBagLayout() ); // controlPanel.add( dateRangeChooser , constraints().noResizing().end() ); controlPanel.add(dateRangeChooser);/* ww w . jav a 2s . c o m*/ dateRangeChooser.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { changeDateRange((DisplayRange) dateRangeChooser.getSelectedItem()); } }); // moving avg. chooser this.movingAverageChooser .setModel(new DefaultComboBoxModel<MovingAverage>(Arrays.asList(MovingAverage.values()))); this.movingAverageChooser.setSelectedItem(MovingAverage.FIVE_DAYS); this.movingAverageChooser.addActionListener(actionListener); controlPanel.add(movingAverageChooser); final JPanel result = new JPanel(); result.setBackground(Color.WHITE); result.setLayout(new GridBagLayout()); final JPanel freeChartPanel = createFreeChartPanel(); // attention: chart must always be // populated AFTER date range chooser is set up because // this calculates earliest/latest dates from dataset // panel.setPreferredSize( new Dimension(500,200 ) ); result.add(controlPanel, constraints(0, 0).resizeBoth().weightX(0.2).weightY(0.2).end()); result.add(freeChartPanel, constraints(0, 1).resizeBoth().end()); return result; }
From source file:fxts.stations.trader.ui.dialogs.CalendarComboBoxes.java
/** * Fills the days combo box/* w w w. ja va2 s . co m*/ */ private void fillDateComboBox() { if (mDateListener == null) { mDateListener = new ItemListener() { public void itemStateChanged(ItemEvent aEvent) { if (aEvent.getStateChange() == ItemEvent.SELECTED) { mCalendarNew.setTime(mCalendar.getTime()); mCalendarNew.set(Calendar.DATE, mDateComboBox.getSelectedIndex() + 1); changeDate(mCalendarNew.getTime()); } } }; } else { mDateComboBox.removeItemListener(mDateListener); } int savedSelectedIndex = mDateComboBox.getSelectedIndex(); int maxDay = mCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); mDateComboBox.removeAllItems(); for (int i = 1; i <= maxDay; i++) { mDateComboBox.addItem(new Integer(i)); } try { mDateComboBox.setSelectedIndex(savedSelectedIndex); } catch (Exception e) { mDateComboBox.setSelectedIndex(0); } mDateComboBox.addItemListener(mDateListener); }
From source file:gdt.jgui.entity.query.JQueryPanel.java
/** * The default constructor.//from ww w . jav a2 s.c o m */ public JQueryPanel() { GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 100, 0, 0 }; gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0 }; setLayout(gridBagLayout); JLabel lblElement = new JLabel("Element"); GridBagConstraints gbc_lblElement = new GridBagConstraints(); gbc_lblElement.insets = new Insets(5, 5, 5, 5); gbc_lblElement.gridx = 0; gbc_lblElement.gridy = 0; gbc_lblElement.anchor = GridBagConstraints.FIRST_LINE_START; add(lblElement, gbc_lblElement); elementComboBox = new JComboBox<String>(); GridBagConstraints gbc_elementComboBox = new GridBagConstraints(); gbc_elementComboBox.fill = GridBagConstraints.HORIZONTAL; gbc_elementComboBox.insets = new Insets(0, 0, 5, 0); gbc_elementComboBox.gridx = 1; gbc_elementComboBox.gridy = 0; gbc_elementComboBox.anchor = GridBagConstraints.FIRST_LINE_START; add(elementComboBox, gbc_elementComboBox); elementComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { try { initItemNameSelector(); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); JLabel lblItemNameField = new JLabel("Item field"); GridBagConstraints gbc_lblItemField = new GridBagConstraints(); gbc_lblItemField.insets = new Insets(5, 5, 5, 5); gbc_lblItemField.gridx = 0; gbc_lblItemField.gridy = 1; gbc_lblItemField.anchor = GridBagConstraints.FIRST_LINE_START; add(lblItemNameField, gbc_lblItemField); itemNameFieldComboBox = new JComboBox<String>(); GridBagConstraints gbc_itemNameFieldComboBox = new GridBagConstraints(); gbc_itemNameFieldComboBox.insets = new Insets(0, 0, 5, 0); gbc_itemNameFieldComboBox.fill = GridBagConstraints.HORIZONTAL; gbc_itemNameFieldComboBox.gridx = 1; gbc_itemNameFieldComboBox.gridy = 1; gbc_itemNameFieldComboBox.anchor = GridBagConstraints.FIRST_LINE_START; add(itemNameFieldComboBox, gbc_itemNameFieldComboBox); itemNameFieldComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { try { initItemNameSelector(); initItemValueSelector(); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); JLabel itemTitle = new JLabel("Item title"); GridBagConstraints gbc_lblItemtitle = new GridBagConstraints(); gbc_lblItemtitle.insets = new Insets(5, 5, 5, 5); gbc_lblItemtitle.gridx = 0; gbc_lblItemtitle.gridy = 2; gbc_lblItemtitle.anchor = GridBagConstraints.FIRST_LINE_START; add(itemTitle, gbc_lblItemtitle); itemNameComboBox = new JComboBox<String>(); GridBagConstraints gbc_itemComboBox = new GridBagConstraints(); gbc_itemComboBox.insets = new Insets(0, 0, 5, 0); gbc_itemComboBox.fill = GridBagConstraints.HORIZONTAL; gbc_itemComboBox.gridx = 1; gbc_itemComboBox.gridy = 2; gbc_itemComboBox.anchor = GridBagConstraints.FIRST_LINE_START; add(itemNameComboBox, gbc_itemComboBox); itemNameComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { try { initItemValueSelector(); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } }); JLabel itemValue = new JLabel("Item value"); GridBagConstraints gbc_lblItemValue = new GridBagConstraints(); gbc_lblItemValue.insets = new Insets(5, 5, 5, 5); gbc_lblItemValue.weighty = 0.0; gbc_lblItemValue.gridx = 0; gbc_lblItemValue.gridy = 3; gbc_lblItemValue.anchor = GridBagConstraints.FIRST_LINE_START; add(itemValue, gbc_lblItemValue); itemValueComboBox = new JComboBox<String>(); GridBagConstraints gbc_itemValueComboBox = new GridBagConstraints(); gbc_itemValueComboBox.insets = new Insets(0, 0, 5, 0); gbc_itemValueComboBox.fill = GridBagConstraints.HORIZONTAL; gbc_itemValueComboBox.gridx = 1; gbc_itemValueComboBox.gridy = 3; gbc_itemValueComboBox.anchor = GridBagConstraints.FIRST_LINE_START; add(itemValueComboBox, gbc_itemValueComboBox); table = new JTable(); JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(java.awt.event.MouseEvent evt) { int row = table.rowAtPoint(evt.getPoint()); int col = table.columnAtPoint(evt.getPoint()); System.out.println("JQueryPanel:cell click:row=" + row + " column=" + col); if (col == 1) { String label$ = (String) table.getValueAt(row, 1); System.out.println("JQueryPanel:cell click:label=" + label$); Entigrator entigrator = console.getEntigrator(entihome$); String entity$ = entigrator.indx_keyAtLabel(label$); JEntityFacetPanel efp = new JEntityFacetPanel(); String efpLocator$ = efp.getLocator(); efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$); efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entity$); JConsoleHandler.execute(console, efpLocator$); } } }); GridBagConstraints gbc_scroll_panel = new GridBagConstraints(); gbc_scroll_panel.anchor = GridBagConstraints.NORTH; gbc_scroll_panel.gridwidth = 2; gbc_scroll_panel.weighty = 1.0; gbc_scroll_panel.fill = GridBagConstraints.HORIZONTAL; gbc_scroll_panel.gridx = 0; gbc_scroll_panel.gridy = 4; add(scrollPane, gbc_scroll_panel); scrollPane.setMinimumSize(scrollPane.getPreferredSize()); }
From source file:Main.java
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row) { Component editor = renderer.getTreeCellRendererComponent(tree, value, true, expanded, leaf, row, true); ItemListener itemListener = new ItemListener() { public void itemStateChanged(ItemEvent itemEvent) { if (stopCellEditing()) { fireEditingStopped();/*w w w .j a v a2s. co m*/ } } }; if (editor instanceof JCheckBox) { ((JCheckBox) editor).addItemListener(itemListener); } return editor; }
From source file:edu.gmu.cs.sim.util.media.chart.XYChartGenerator.java
protected void buildGlobalAttributes(LabelledList list) { // create the chart ((XYPlot) (chart.getPlot())).setDomainGridlinesVisible(false); ((XYPlot) (chart.getPlot())).setRangeGridlinesVisible(false); ((XYPlot) (chart.getPlot())).setDomainGridlinePaint(new Color(200, 200, 200)); ((XYPlot) (chart.getPlot())).setRangeGridlinePaint(new Color(200, 200, 200)); xLabel = new PropertyField() { public String newValue(String newValue) { setXAxisLabel(newValue);/*from ww w.ja va2 s .c o m*/ getChartPanel().repaint(); return newValue; } }; xLabel.setValue(getXAxisLabel()); list.add(new JLabel("X Label"), xLabel); yLabel = new PropertyField() { public String newValue(String newValue) { setYAxisLabel(newValue); getChartPanel().repaint(); return newValue; } }; yLabel.setValue(getYAxisLabel()); list.add(new JLabel("Y Label"), yLabel); xLog = new JCheckBox(); xLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (xLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(xLabel.getValue()); logAxis.setStrictValuesFlag(false); chart.getXYPlot().setDomainAxis(logAxis); } else { chart.getXYPlot().setDomainAxis(new NumberAxis(xLabel.getValue())); } } }); yLog = new JCheckBox(); yLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (yLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(yLabel.getValue()); logAxis.setStrictValuesFlag(false); chart.getXYPlot().setRangeAxis(logAxis); } else { chart.getXYPlot().setRangeAxis(new NumberAxis(yLabel.getValue())); } } }); Box box = Box.createHorizontalBox(); box.add(new JLabel("X")); box.add(xLog); box.add(new JLabel(" Y")); box.add(yLog); box.add(Box.createGlue()); list.add(new JLabel("Log Axis"), box); final JCheckBox xgridlines = new JCheckBox(); xgridlines.setSelected(false); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { chart.getXYPlot().setDomainGridlinesVisible(true); } else { chart.getXYPlot().setDomainGridlinesVisible(false); } } }; xgridlines.addItemListener(il); final JCheckBox ygridlines = new JCheckBox(); ygridlines.setSelected(false); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { chart.getXYPlot().setRangeGridlinesVisible(true); } else { chart.getXYPlot().setRangeGridlinesVisible(false); } } }; ygridlines.addItemListener(il); box = Box.createHorizontalBox(); box.add(new JLabel("X")); box.add(xgridlines); box.add(new JLabel(" Y")); box.add(ygridlines); box.add(Box.createGlue()); list.add(new JLabel("Grid Lines"), box); }
From source file:com.intuit.tank.tools.script.ScriptFilterRunner.java
/** * @return/* ww w. j av a2 s . co m*/ */ private Component createTopPanel() { JPanel topPanel = new JPanel(new GridBagLayout()); List<ConfiguredLanguage> configuredLanguages = ConfiguredLanguage.getConfiguredLanguages(); languageSelector = new JComboBox(configuredLanguages.toArray()); languageSelector.setSelectedIndex(0); languageSelector.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { setSyntaxStyle(); } }); currentFileLabel = new JLabel(); final JFileChooser jFileChooser = new JFileChooser(); jFileChooser.setFileFilter(new FileFilter() { @Override public String getDescription() { return "Tank XML Files"; } @Override public boolean accept(File f) { return f.isDirectory() || f.getName().toLowerCase().endsWith("_ts.xml"); } }); JButton button = new JButton("Select File..."); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int showOpenDialog = jFileChooser.showOpenDialog(ScriptFilterRunner.this); if (showOpenDialog == JFileChooser.APPROVE_OPTION) { loadTSXml(jFileChooser.getSelectedFile()); } } }); xmlViewDialog = new XMlViewDialog(this); xmlViewDialog.setSize(new Dimension(800, 500)); showXmlBT = new JButton("Show XML"); showXmlBT.setEnabled(false); showXmlBT.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { displayXml(); } }); saveBT = new JButton("Save XML"); saveBT.setEnabled(false); saveBT.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveXml(); } }); JPanel xmlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 20)); xmlPanel.add(button); xmlPanel.add(showXmlBT); xmlPanel.add(saveBT); int y = 0; topPanel.add(new JLabel("Current Tank XML: "), getConstraints(0, y, GridBagConstraints.NONE)); topPanel.add(currentFileLabel, getConstraints(1, y++, GridBagConstraints.HORIZONTAL)); topPanel.add(new JLabel("Select Script Language: "), getConstraints(0, y, GridBagConstraints.NONE)); topPanel.add(languageSelector, getConstraints(1, y++, GridBagConstraints.HORIZONTAL)); topPanel.add(new JLabel("Select Tank XML: "), getConstraints(0, y, GridBagConstraints.NONE)); topPanel.add(xmlPanel, getConstraints(1, y++, GridBagConstraints.HORIZONTAL)); return topPanel; }
From source file:sim.util.media.chart.XYChartGenerator.java
protected void buildGlobalAttributes(LabelledList list) { // create the chart ((XYPlot) (chart.getPlot())).setDomainGridlinesVisible(false); ((XYPlot) (chart.getPlot())).setRangeGridlinesVisible(false); ((XYPlot) (chart.getPlot())).setDomainGridlinePaint(new Color(200, 200, 200)); ((XYPlot) (chart.getPlot())).setRangeGridlinePaint(new Color(200, 200, 200)); xLabel = new PropertyField() { public String newValue(String newValue) { setXAxisLabel(newValue);/*from w w w . j a v a2s .c om*/ getChartPanel().repaint(); return newValue; } }; xLabel.setValue(getXAxisLabel()); list.add(new JLabel("X Label"), xLabel); yLabel = new PropertyField() { public String newValue(String newValue) { setYAxisLabel(newValue); getChartPanel().repaint(); return newValue; } }; yLabel.setValue(getYAxisLabel()); list.add(new JLabel("Y Label"), yLabel); xLog = new JCheckBox(); xLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (xLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(xLabel.getValue()); logAxis.setStrictValuesFlag(false); chart.getXYPlot().setDomainAxis(logAxis); } else chart.getXYPlot().setDomainAxis(new NumberAxis(xLabel.getValue())); } }); yLog = new JCheckBox(); yLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (yLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(yLabel.getValue()); logAxis.setStrictValuesFlag(false); chart.getXYPlot().setRangeAxis(logAxis); } else chart.getXYPlot().setRangeAxis(new NumberAxis(yLabel.getValue())); } }); Box box = Box.createHorizontalBox(); box.add(new JLabel("X")); box.add(xLog); box.add(new JLabel(" Y")); box.add(yLog); box.add(Box.createGlue()); list.add(new JLabel("Log Axis"), box); final JCheckBox xgridlines = new JCheckBox(); xgridlines.setSelected(false); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { chart.getXYPlot().setDomainGridlinesVisible(true); } else { chart.getXYPlot().setDomainGridlinesVisible(false); } } }; xgridlines.addItemListener(il); final JCheckBox ygridlines = new JCheckBox(); ygridlines.setSelected(false); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { chart.getXYPlot().setRangeGridlinesVisible(true); } else { chart.getXYPlot().setRangeGridlinesVisible(false); } } }; ygridlines.addItemListener(il); box = Box.createHorizontalBox(); box.add(new JLabel("X")); box.add(xgridlines); box.add(new JLabel(" Y")); box.add(ygridlines); box.add(Box.createGlue()); list.add(new JLabel("Grid Lines"), box); }
From source file:org.ut.biolab.medsavant.client.filter.TagFilterView.java
public TagFilterView(int queryID) { super(FILTER_NAME, queryID); setLayout(new BorderLayout()); setBorder(ViewUtil.getBigBorder());//from w w w.j ava 2s .c om setMaximumSize(new Dimension(200, 80)); JPanel cp = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; cp.setLayout(gbl); variantTags = new ArrayList<VariantTag>(); appliedTags = new ArrayList<VariantTag>(); clear = new JButton("Clear"); applyButton = new JButton("Apply"); try { final JComboBox tagNameCB = new JComboBox(); //tagNameCB.setMaximumSize(new Dimension(1000,30)); final JComboBox tagValueCB = new JComboBox(); //tagValueCB.setMaximumSize(new Dimension(1000,30)); JPanel bottomContainer = new JPanel(); ViewUtil.applyHorizontalBoxLayout(bottomContainer); List<String> tagNames = MedSavantClient.VariantManager .getDistinctTagNames(LoginController.getSessionID()); for (String tag : tagNames) { tagNameCB.addItem(tag); } ta = new JTextArea(); ta.setRows(10); ta.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); ta.setEditable(false); applyButton.setEnabled(false); JLabel addButton = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.ADD)); addButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (tagNameCB.getSelectedItem() == null || tagValueCB.getSelectedItem() == null) { return; } VariantTag tag = new VariantTag((String) tagNameCB.getSelectedItem(), (String) tagValueCB.getSelectedItem()); if (variantTags.isEmpty()) { ta.append(tag.toString() + "\n"); } else { ta.append("AND " + tag.toString() + "\n"); } variantTags.add(tag); applyButton.setEnabled(true); } }); clear.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { variantTags.clear(); ta.setText(""); applyButton.setEnabled(true); } }); int width = 150; ta.setPreferredSize(new Dimension(width, width)); ta.setMaximumSize(new Dimension(width, width)); tagNameCB.setPreferredSize(new Dimension(width, 25)); tagValueCB.setPreferredSize(new Dimension(width, 25)); tagNameCB.setMaximumSize(new Dimension(width, 25)); tagValueCB.setMaximumSize(new Dimension(width, 25)); cp.add(new JLabel("Name"), c); c.gridx++; cp.add(tagNameCB, c); c.gridx++; c.gridx = 0; c.gridy++; cp.add(new JLabel("Value"), c); c.gridx++; cp.add(tagValueCB, c); c.gridx++; cp.add(addButton, c); tagNameCB.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent ie) { updateTagValues((String) tagNameCB.getSelectedItem(), tagValueCB); } }); if (tagNameCB.getItemCount() > 0) { tagNameCB.setSelectedIndex(0); updateTagValues((String) tagNameCB.getSelectedItem(), tagValueCB); } al = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { applyButton.setEnabled(false); appliedTags = new ArrayList<VariantTag>(variantTags); Filter f = new Filter() { @Override public Condition[] getConditions() { try { List<Integer> uploadIDs = MedSavantClient.VariantManager .getUploadIDsMatchingVariantTags(LoginController.getSessionID(), TagFilterView.tagsToStringArray(variantTags)); Condition[] uploadIDConditions = new Condition[uploadIDs.size()]; TableSchema table = MedSavantClient.CustomTablesManager.getCustomTableSchema( LoginController.getSessionID(), MedSavantClient.ProjectManager.getVariantTableName( LoginController.getSessionID(), ProjectController.getInstance().getCurrentProjectID(), ReferenceController.getInstance().getCurrentReferenceID(), true)); for (int i = 0; i < uploadIDs.size(); i++) { uploadIDConditions[i] = BinaryCondition.equalTo( table.getDBColumn(BasicVariantColumns.UPLOAD_ID), uploadIDs.get(i)); } return new Condition[] { ComboCondition.or(uploadIDConditions) }; } catch (Exception ex) { ClientMiscUtils.reportError("Error getting upload IDs: %s", ex); } return new Condition[0]; } @Override public String getName() { return FILTER_NAME; } @Override public String getID() { return FILTER_ID; } }; FilterController.getInstance().addFilter(f, TagFilterView.this.queryID); } }; applyButton.addActionListener(al); bottomContainer.add(Box.createHorizontalGlue()); bottomContainer.add(clear); bottomContainer.add(applyButton); add(ViewUtil.getClearBorderedScrollPane(ta), BorderLayout.CENTER); add(bottomContainer, BorderLayout.SOUTH); } catch (Exception ex) { ClientMiscUtils.checkSQLException(ex); } add(cp, BorderLayout.NORTH); this.showViewCard(); }