List of usage examples for java.awt.event ItemEvent SELECTED
int SELECTED
To view the source code for java.awt.event ItemEvent SELECTED.
Click Source Link
From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryFieldPanel.java
/** * @param iconSize// w ww . j a v a 2s.c om * @param returnWidths * @return */ protected int[] buildControlLayout(final IconManager.IconSize iconSize, final boolean returnWidths, final Component saveBtn) { FocusListener focusListener = new FocusListener() { /* * (non-Javadoc) * * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent) */ // @Override public void focusGained(FocusEvent e) { //Checking oppositeComponent to work around //weird behavior after addBtn is clicked which //causes top queryFieldPanel to be selected. if (ownerQuery.getAddBtn() != null && e.getOppositeComponent() != ownerQuery.getAddBtn()) { ownerQuery.selectQFP(QueryFieldPanel.this); } } /* * (non-Javadoc) * * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent) */ // @Override public void focusLost(FocusEvent e) { // nada } }; KeyListener enterListener = new KeyListener() { @Override public void keyPressed(KeyEvent arg0) { //nuthin } @Override public void keyReleased(KeyEvent arg0) { //nuthin } @Override public void keyTyped(KeyEvent arg0) { if (arg0.getKeyChar() == KeyEvent.VK_ENTER && ownerQuery != null) { ownerQuery.doSearch(); } } }; comparators = getComparatorList(fieldQRI); //XXX need to build schemaItem for header panel too... if (schemaMapping != null) { schemaItemCBX = edu.ku.brc.ui.UIHelper.createComboBox(); schemaItemCBX.addItem("empty"); //to work around validator blow up for empty lists. DataChangeNotifier dcnsi = validator.hookupComponent(schemaItemCBX, "sicbx", UIValidator.Type.Changed, "", true); schemaItemCBX.addActionListener(dcnsi); schemaItemCBX.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (!QueryFieldPanel.this.ownerQuery.isUpdatingAvailableConcepts()) { if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getItem() instanceof SpExportSchemaItem) { QueryFieldPanel.this.schemaItem = (SpExportSchemaItem) e.getItem(); } else { SpExportSchemaItemMapping m = QueryFieldPanel.this.getItemMapping(); SpExportSchemaItem si = QueryFieldPanel.this.schemaItem; String item = e.getItem().toString(); if (StringUtils.isNotBlank(item) && ownerQuery.isAvailableExportFieldName(QueryFieldPanel.this, item)) { if (m != null) { m.setExportedFieldName(e.getItem().toString()); } if (si != null) { si.setFieldName(e.getItem().toString()); } } else { if (StringUtils.isBlank(item)) { UIRegistry.displayErrorDlgLocalized( "QueryFieldPanel.ExportFieldNameInvalid", item); } else { UIRegistry.displayErrorDlgLocalized( "QueryFieldPanel.ExportFieldNameAlreadyUsed", item); } schemaItemCBX.setSelectedIndex(0); } } ownerQuery.updateAvailableConcepts(); } } } }); } else { schemaItemCBX = null; } iconLabel = new JLabel(icon); iconLabel.addFocusListener(focusListener); String fieldLabelText = fieldQRI != null ? fieldQRI.getTitle() : "WXYZ"; if (fieldQRI instanceof RelQRI) { DBRelationshipInfo.RelationshipType relType = ((RelQRI) fieldQRI).getRelationshipInfo().getType(); if (relType.equals(DBRelationshipInfo.RelationshipType.OneToMany) || relType.equals(DBRelationshipInfo.RelationshipType.ManyToMany)) { fieldLabelText += " " + UIRegistry.getResourceString("QB_AGGREGATED"); } else { fieldLabelText += " " + UIRegistry.getResourceString("QB_FORMATTED"); } } fieldLabel = createLabel(fieldLabelText); fieldLabel.addFocusListener(focusListener); fieldLabel.addKeyListener(enterListener); isNotCheckbox = createCheckBox("isNotCheckbox"); isNotCheckbox.addFocusListener(focusListener); isNotCheckbox.addKeyListener(enterListener); operatorCBX = createComboBox(comparators); operatorCBX.addFocusListener(focusListener); operatorCBX.addKeyListener(enterListener); boolean isBool = fieldQRI != null && fieldQRI.getDataClass().equals(Boolean.class); if (!isBool) { operatorCBX.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { criteria.setVisible(!operatorCBX.getSelectedItem().equals(SpQueryField.OperatorType.EMPTY)); } } }); } if (pickList == null) { boolean hasBetweenOp = false; for (int o = 0; o < comparators.length; o++) { if (comparators[o].equals(OperatorType.BETWEEN)) { hasBetweenOp = true; break; } } if (hasBetweenOp) { criteria = new CriteriaPair(enterListener); operatorCBX.addActionListener(this); } else { criteria = createTextField("1"); criteria.addKeyListener(enterListener); } } else { criteria = createPickList(saveBtn); if (!ownerQuery.isPromptMode()) { ((PickListCriteriaCombo) criteria) .setCurrentOp((SpQueryField.OperatorType) operatorCBX.getModel().getElementAt(0)); } criteria.addKeyListener(enterListener); operatorCBX.addItemListener(new ItemListener() { /* * (non-Javadoc) * * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent) */ //@Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { // System.out.println("setting curront op"); ((PickListCriteriaCombo) criteria) .setCurrentOp((SpQueryField.OperatorType) operatorCBX.getSelectedItem()); } } }); } //criteria.addFocusListener(focusListener); sortCheckbox = new MultiStateIconButon( new ImageIcon[] { IconManager.getImage("GrayDot", IconManager.IconSize.Std16), IconManager.getImage("UpArrow", IconManager.IconSize.Std16), IconManager.getImage("DownArrow", IconManager.IconSize.Std16) }); DataChangeNotifier dcn = validator.hookupComponent(sortCheckbox, "scb", UIValidator.Type.Changed, "", true); sortCheckbox.addFocusListener(focusListener); sortCheckbox.addActionListener(dcn); sortCheckbox.addKeyListener(enterListener); if (!this.ownerQuery.isPromptMode()) { isEnforcedCkbx = createCheckBox("isEnforcedCkbx"); dcn = validator.hookupComponent(isEnforcedCkbx, "iecb", UIValidator.Type.Changed, "", true); isEnforcedCkbx.addActionListener(dcn); isEnforcedCkbx.addFocusListener(focusListener); isEnforcedCkbx.addKeyListener(enterListener); } if (!this.ownerQuery.isPromptMode()) { isDisplayedCkbx = createCheckBox("isDisplayedCkbx"); dcn = validator.hookupComponent(isDisplayedCkbx, "idcb", UIValidator.Type.Changed, "", true); isDisplayedCkbx.addFocusListener(focusListener); isDisplayedCkbx.addKeyListener(enterListener); isDisplayedCkbx.addActionListener(dcn); isDisplayedCkbx.addActionListener(new ActionListener() { /* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @Override public void actionPerformed(ActionEvent arg0) { SwingUtilities.invokeLater(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { sortCheckbox.setEnabled(isDisplayedCkbx.isSelected()); ownerQuery.changeNotification(QueryFieldPanel.this); } }); } }); isPromptCkbx = createCheckBox("isPromptCkbx"); dcn = validator.hookupComponent(isPromptCkbx, "ipcb", UIValidator.Type.Changed, "", true); isPromptCkbx.addActionListener(dcn); isPromptCkbx.addFocusListener(focusListener); isPromptCkbx.addKeyListener(enterListener); closeBtn = edu.ku.brc.ui.UIHelper.createIconBtn("Close", "QB_REMOVE_FLD", new ActionListener() { public void actionPerformed(ActionEvent ae) { boolean clearIt = schemaItem != null; ownerQuery.removeQueryFieldItem((QueryFieldPanel) ((JComponent) ae.getSource()).getParent()); if (clearIt) { setField(null, null); } } }); closeBtn.setEnabled(true); closeBtn.setFocusable(false); closeBtn.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { ((JButton) e.getSource()).setIcon(IconManager.getIcon("CloseHover")); super.mouseEntered(e); } @Override public void mouseExited(MouseEvent e) { ((JButton) e.getSource()).setIcon(IconManager.getIcon("Close")); super.mouseExited(e); } }); } else { isDisplayedCkbx = null; this.isPromptCkbx = null; this.isEnforcedCkbx = null; this.closeBtn = null; } JComponent[] qComps = { iconLabel, fieldLabel, isNotCheckbox, operatorCBX, criteria, sortCheckbox, isDisplayedCkbx, isPromptCkbx, isEnforcedCkbx, closeBtn, null }; JComponent[] sComps = { schemaItemCBX, iconLabel, fieldLabel, isNotCheckbox, operatorCBX, criteria, sortCheckbox, isDisplayedCkbx, isEnforcedCkbx, closeBtn, null }; // 0 1 2 3 4 5 6 7 8 9 if (schemaMapping == null) { comps = qComps; } else { comps = sComps; } StringBuilder sb = new StringBuilder(); Integer[] qFixedCmps = { 300 }; Integer[] sFixedCmps = { 268, 300 }; Integer[] fixedCmps; if (schemaMapping != null) { fixedCmps = sFixedCmps; } else { fixedCmps = qFixedCmps; } if (columnDefStr == null) { for (int i = 0; i < comps.length; i++) { sb.append(i == 0 ? "" : ","); if (isCenteredComp(i)) sb.append("c:"); if (i >= fixedCmps.length) { sb.append("p"); } else { sb.append(fixedCmps[i] + "px"); } if (isGrowComp(i)) sb.append(":g"); sb.append(",4px"); } } else { sb.append(columnDefStr); } PanelBuilder builder = new PanelBuilder(new FormLayout("3px, " + sb.toString() + ", 3px", "3px, p, 3px"), this); CellConstraints cc = new CellConstraints(); int col = 1; for (JComponent comp : comps) { if (comp != null) { builder.add(comp, cc.xy(col + 1, 2)); } col += 2; } if (fieldQRI != null) { icon = IconManager.getIcon(fieldQRI.getTableInfo().getName(), iconSize); setIcon(icon); } if (!ownerQuery.isPromptMode()) { isDisplayedCkbx.setSelected(true); isPromptCkbx.setSelected(!(fieldQRI instanceof RelQRI)); isEnforcedCkbx.setSelected(false); } if (fieldQRI == null && !returnWidths) { for (int c = 1; c < comps.length; c++) { if (comps[c] != null) { comps[c].setVisible(false); } } } else { // for now boolean isRel = fieldQRI != null && fieldQRI instanceof RelQRI; boolean isTreeLevel = fieldQRI instanceof TreeLevelQRI; isNotCheckbox.setVisible(!isRel || pickList != null); operatorCBX.setVisible(!isRel || pickList != null); criteria.setVisible((!isRel && !isBool) || pickList != null); if (schemaMapping != null) { this.sortCheckbox.setVisible(!(isTreeLevel || isRel)); } else { if (!isRel) { this.sortCheckbox.setVisible(true); } else { this.sortCheckbox.setVisible( ((RelQRI) fieldQRI).getRelationshipInfo().getType() != RelationshipType.OneToMany); } } if (!ownerQuery.isPromptMode()) { isDisplayedCkbx.setVisible(!isRel); isPromptCkbx.setVisible(!isRel); isEnforcedCkbx.setVisible(!isRel); } } validate(); doLayout(); int[] widths = null; if (returnWidths) { widths = new int[comps.length]; for (int i = 0; i < comps.length; i++) { widths[i] = comps[i] != null ? comps[i].getSize().width : 0; } if (this.schemaMapping == null) { widths[0] = iconSize.size(); widths[1] = 200; } else { widths[1] = iconSize.size(); widths[2] = 200; } } return widths; }
From source file:op.controlling.PnlControlling.java
private java.util.List<Component> addFilters() { java.util.List<Component> list = new ArrayList<Component>(); if (tabMain.getSelectedIndex() == TAB_QMSPLAN) { final JToggleButton tbClosedOnes2 = GUITools .getNiceToggleButton(SYSTools.xx("misc.filters.showclosed")); ArrayList<Commontags> listTags = CommontagsTools.getAllUsedInQMSPlans(true); if (!listTags.isEmpty()) { JPanel pnlTags = new JPanel(); pnlTags.setLayout(new BoxLayout(pnlTags, BoxLayout.PAGE_AXIS)); pnlTags.setOpaque(false);/*w w w.ja va2 s . co m*/ final JButton btnReset = GUITools.createHyperlinkButton("misc.commands.resetFilter", SYSConst.icon16tagPurpleDelete4, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // init = true; // tbClosedOnes2.setSelected(false); // init = false; // pnlQMSPlan.reload(); // // pnlQMSPlan.cleanup(); // pnlQMSPlan = new PnlQMSPlan(null); // tabMain.setComponentAt(TAB_QMSPLAN, pnlQMSPlan); filterTag = null; tbClosedOnes2.setSelected(false); } }); pnlTags.add(btnReset, RiverLayout.LEFT); for (final Commontags commontag : listTags) { final JButton btnTag = GUITools.createHyperlinkButton(commontag.getText(), SYSConst.icon16tagPurple, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // init = true; // tbClosedOnes2.setSelected(true); // init = false; // // pnlQMSPlan.cleanup(); // pnlQMSPlan = new PnlQMSPlan(null); // tabMain.setComponentAt(TAB_QMSPLAN, pnlQMSPlan); // //TODO: mark the filter when it is used. maybe a yellow background filterTag = commontag; tbClosedOnes2.setSelected(true); } }); pnlTags.add(btnTag); } list.add(pnlTags); } tbClosedOnes2.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { // if (init) return; pnlQMSPlan.reload(filterTag, itemEvent.getStateChange() == ItemEvent.SELECTED); } }); list.add(tbClosedOnes2); tbClosedOnes2.setHorizontalAlignment(SwingConstants.LEFT); } return list; }
From source file:org.smart.migrate.ui.MigrateMain.java
private void cbxSrcDBTypeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbxSrcDBTypeItemStateChanged if (ItemEvent.SELECTED == evt.getStateChange()) { DBType dBType = (DBType) evt.getItem(); edtSrcDBHost.setText("127.0.0.1"); edtSrcDBPort.setText(dBType.getDefaultPort()); }// w ww. jav a2s .c o m }
From source file:org.smart.migrate.ui.MigrateMain.java
private void cbxTgtDBTypeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbxTgtDBTypeItemStateChanged // TODO add your handling code here: if (ItemEvent.SELECTED == evt.getStateChange()) { DBType dBType = (DBType) evt.getItem(); if (StringUtils.isBlank(edtTgtDBHost.getText())) { edtTgtDBHost.setText("127.0.0.1"); edtTgtDBPort.setText(dBType.getDefaultPort()); }/*www . j a v a 2 s .c o m*/ } }
From source file:org.domainmath.gui.MainFrame.java
private void dirComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_dirComboBoxItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { Object s = this.dirComboBox.getSelectedItem(); int n = dirComboBox.getItemCount(); if (dirComboBox.getSelectedIndex() <= -1) { if (n == 0) { dirComboBox.addItem(s);// w w w. ja v a2s. c o m cd(s.toString()); } else { for (int i = 0; i < dirComboBox.getItemCount(); i++) { if (s == dirComboBox.getItemAt(i)) { System.out.println("Repeated"); } else { dirComboBox.removeItem(s); dirComboBox.insertItemAt(s, 0); dirComboBox.setSelectedIndex(0); cd(s.toString()); break; } } } } else { if (dirComboBox.getSelectedIndex() > 0) { Object item = dirComboBox.getSelectedItem(); dirComboBox.removeItem(item); dirComboBox.insertItemAt(item, 0); dirComboBox.setSelectedIndex(0); cd(item.toString()); } } } }
From source file:com.osparking.osparking.Settings_System.java
private void Camera1_TypeCBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_Camera1_TypeCBoxItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { setButtonEnabled_If_DeviceTypeChanged(1, Camera); CameraType camType = (CameraType) (Camera1_TypeCBox.getSelectedItem()); if (camType == CarButton) { Camera1_IP_TextField.setEnabled(false); Camera1_Port_TextField.setEnabled(false); } else {/*from ww w. ja v a 2 s . c o m*/ Camera1_IP_TextField.setEnabled(true); Camera1_Port_TextField.setEnabled(true); } setPortNumber(Camera, camType, (byte) 1, Camera1_Port_TextField); } }
From source file:com.mirth.connect.client.ui.ChannelSetup.java
private void attachmentStoreCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_attachmentStoreCheckBoxItemStateChanged attachmentWarningLabel.setVisible(evt.getStateChange() != ItemEvent.SELECTED && attachmentComboBox.getSelectedItem() != AttachmentHandlerType.NONE); }
From source file:com.osparking.osparking.Settings_System.java
private void Camera2_TypeCBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_Camera2_TypeCBoxItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { setButtonEnabled_If_DeviceTypeChanged(2, Camera); setPortNumber(Camera, Camera2_TypeCBox.getSelectedItem(), (byte) 2, Camera2_Port_TextField); }//from www .j ava 2s.c om }
From source file:com.osparking.osparking.Settings_System.java
private void Camera3_TypeCBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_Camera3_TypeCBoxItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { setButtonEnabled_If_DeviceTypeChanged(3, Camera); setPortNumber(Camera, Camera3_TypeCBox.getSelectedItem(), (byte) 3, Camera3_Port_TextField); }/* w ww .java 2s. c o m*/ }
From source file:com.osparking.osparking.Settings_System.java
private void Camera4_TypeCBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_Camera4_TypeCBoxItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { setButtonEnabled_If_DeviceTypeChanged(4, Camera); setPortNumber(Camera, Camera4_TypeCBox.getSelectedItem(), (byte) 4, Camera4_Port_TextField); }// ww w.j a v a2 s . c o m }