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:net.pms.newgui.NavigationShareTab.java
private PanelBuilder initSharedFoldersGuiComponents(CellConstraints cc) { // Apply the orientation for the locale ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale()); String colSpec = FormLayoutUtil.getColSpec(SHARED_FOLDER_COL_SPEC, orientation); FormLayout layoutFolders = new FormLayout(colSpec, SHARED_FOLDER_ROW_SPEC); PanelBuilder builderFolder = new PanelBuilder(layoutFolders); builderFolder.opaque(true);/*from w w w. j a va 2 s . c o m*/ JComponent cmp = builderFolder.addSeparator(Messages.getString("FoldTab.7"), FormLayoutUtil.flip(cc.xyw(1, 1, 7), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); folderTableModel = new SharedFoldersTableModel(); sharedFolders = new JTable(folderTableModel); JPopupMenu popupMenu = new JPopupMenu(); JMenuItem menuItemMarkPlayed = new JMenuItem(Messages.getString("FoldTab.75")); JMenuItem menuItemMarkUnplayed = new JMenuItem(Messages.getString("FoldTab.76")); menuItemMarkPlayed.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String path = (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0); TableFilesStatus.setDirectoryFullyPlayed(path, true); } }); menuItemMarkUnplayed.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String path = (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0); TableFilesStatus.setDirectoryFullyPlayed(path, false); } }); popupMenu.add(menuItemMarkPlayed); popupMenu.add(menuItemMarkUnplayed); sharedFolders.setComponentPopupMenu(popupMenu); /* An attempt to set the correct row height adjusted for font scaling. * It sets all rows based on the font size of cell (0, 0). The + 4 is * to allow 2 pixels above and below the text. */ DefaultTableCellRenderer cellRenderer = (DefaultTableCellRenderer) sharedFolders.getCellRenderer(0, 0); FontMetrics metrics = cellRenderer.getFontMetrics(cellRenderer.getFont()); sharedFolders.setRowHeight(metrics.getLeading() + metrics.getMaxAscent() + metrics.getMaxDescent() + 4); sharedFolders.setIntercellSpacing(new Dimension(8, 2)); final JPanel tmpsharedPanel = sharedPanel; addButton.setToolTipText(Messages.getString("FoldTab.9")); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser; try { chooser = new JFileChooser(); } catch (Exception ee) { chooser = new JFileChooser(new RestrictedFileSystemView()); } chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = chooser.showOpenDialog((Component) e.getSource()); if (returnVal == JFileChooser.APPROVE_OPTION) { int firstSelectedRow = sharedFolders.getSelectedRow(); if (firstSelectedRow >= 0) { ((SharedFoldersTableModel) sharedFolders.getModel()).insertRow(firstSelectedRow, new Object[] { chooser.getSelectedFile().getAbsolutePath(), true }); } else { ((SharedFoldersTableModel) sharedFolders.getModel()) .addRow(new Object[] { chooser.getSelectedFile().getAbsolutePath(), true }); } } } }); builderFolder.add(addButton, FormLayoutUtil.flip(cc.xy(2, 3), colSpec, orientation)); removeButton.setToolTipText(Messages.getString("FoldTab.36")); removeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] rows = sharedFolders.getSelectedRows(); if (rows.length > 0) { if (rows.length > 1) { if (JOptionPane.showConfirmDialog(tmpsharedPanel, String.format(Messages.getString("SharedFolders.ConfirmRemove"), rows.length), Messages.getString("Dialog.Confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) { return; } } for (int i = rows.length - 1; i >= 0; i--) { PMS.get().getDatabase().removeMediaEntriesInFolder( (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0)); ((SharedFoldersTableModel) sharedFolders.getModel()).removeRow(rows[i]); } } } }); builderFolder.add(removeButton, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation)); arrowDownButton.setToolTipText(Messages.getString("SharedFolders.ArrowDown")); arrowDownButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (int i = 0; i < sharedFolders.getRowCount() - 1; i++) { if (sharedFolders.isRowSelected(i)) { Object value1 = sharedFolders.getValueAt(i, 0); boolean value2 = (boolean) sharedFolders.getValueAt(i, 1); sharedFolders.setValueAt(sharedFolders.getValueAt(i + 1, 0), i, 0); sharedFolders.setValueAt(value1, i + 1, 0); sharedFolders.setValueAt(sharedFolders.getValueAt(i + 1, 1), i, 1); sharedFolders.setValueAt(value2, i + 1, 1); sharedFolders.changeSelection(i + 1, 1, false, false); break; } } } }); builderFolder.add(arrowDownButton, FormLayoutUtil.flip(cc.xy(4, 3), colSpec, orientation)); arrowUpButton.setToolTipText(Messages.getString("SharedFolders.ArrowUp")); arrowUpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (int i = 1; i < sharedFolders.getRowCount(); i++) { if (sharedFolders.isRowSelected(i)) { Object value1 = sharedFolders.getValueAt(i, 0); boolean value2 = (boolean) sharedFolders.getValueAt(i, 1); sharedFolders.setValueAt(sharedFolders.getValueAt(i - 1, 0), i, 0); sharedFolders.setValueAt(value1, i - 1, 0); sharedFolders.setValueAt(sharedFolders.getValueAt(i - 1, 1), i, 1); sharedFolders.setValueAt(value2, i - 1, 1); sharedFolders.changeSelection(i - 1, 1, false, false); break; } } } }); builderFolder.add(arrowUpButton, FormLayoutUtil.flip(cc.xy(5, 3), colSpec, orientation)); scanButton.setToolTipText(Messages.getString("FoldTab.2")); scanBusyIcon.start(); scanBusyDisabledIcon.start(); scanButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (configuration.getUseCache()) { DLNAMediaDatabase database = PMS.get().getDatabase(); if (database != null) { if (database.isScanLibraryRunning()) { int option = JOptionPane.showConfirmDialog(looksFrame, Messages.getString("FoldTab.10"), Messages.getString("Dialog.Question"), JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { database.stopScanLibrary(); looksFrame.setStatusLine(Messages.getString("FoldTab.41")); scanButton.setEnabled(false); scanButton.setToolTipText(Messages.getString("FoldTab.41")); } } else { database.scanLibrary(); scanButton.setIcon(scanBusyIcon); scanButton.setRolloverIcon(scanBusyRolloverIcon); scanButton.setPressedIcon(scanBusyPressedIcon); scanButton.setDisabledIcon(scanBusyDisabledIcon); scanButton.setToolTipText(Messages.getString("FoldTab.40")); } } } } }); /* * Hide the scan button in basic mode since it's better to let it be done in * realtime. */ if (!configuration.isHideAdvancedOptions()) { builderFolder.add(scanButton, FormLayoutUtil.flip(cc.xy(6, 3), colSpec, orientation)); } scanButton.setEnabled(configuration.getUseCache()); isScanSharedFoldersOnStartup = new JCheckBox(Messages.getString("NetworkTab.StartupScan"), configuration.isScanSharedFoldersOnStartup()); isScanSharedFoldersOnStartup.setToolTipText(Messages.getString("NetworkTab.StartupScanTooltip")); isScanSharedFoldersOnStartup.setContentAreaFilled(false); isScanSharedFoldersOnStartup.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setScanSharedFoldersOnStartup((e.getStateChange() == ItemEvent.SELECTED)); } }); builderFolder.add(isScanSharedFoldersOnStartup, FormLayoutUtil.flip(cc.xy(7, 3), colSpec, orientation)); updateSharedFolders(); JScrollPane pane = new JScrollPane(sharedFolders); Dimension d = sharedFolders.getPreferredSize(); pane.setPreferredSize(new Dimension(d.width, sharedFolders.getRowHeight() * 2)); builderFolder.add(pane, FormLayoutUtil.flip(cc.xyw(1, 5, 7, CellConstraints.DEFAULT, CellConstraints.FILL), colSpec, orientation)); return builderFolder; }
From source file:io.github.jeddict.jpa.modeler.source.generator.ui.GenerateCodeDialog.java
private void businessLayerComboItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_businessLayerComboItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { setCompleteApplicationCompVisibility( getBusinessLayer().getTechnology().panel() != LayerConfigPanel.class); changeBusinessLayer(getBusinessLayer()); }//www. j a v a 2 s.c om }
From source file:op.care.supervisor.PnlHandover.java
private List<Component> addFilters() { List<Component> list = new ArrayList<Component>(); Pair<DateTime, DateTime> minmax = NReportTools.getMinMax(); if (minmax != null) { final DefaultComboBoxModel yearModel = new DefaultComboBoxModel(); for (int year = new LocalDate().getYear(); year >= minmax.getFirst().getYear(); year--) { yearModel.addElement(year);//from w w w . jav a2 s . c om } JPanel innerPanel = new JPanel(); innerPanel.setOpaque(false); innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.PAGE_AXIS)); txtSearch = new JXSearchField(SYSTools.xx("misc.msg.searchphrase")); txtSearch.setInstantSearchDelay(100000); txtSearch.setFont(SYSConst.ARIAL14); txtSearch.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (SYSTools.catchNull(txtSearch.getText()).trim().length() > 3) { SYSFilesTools.print(NReportTools.getReportsAndHandoversAsHTML( NReportTools.getNReports4Handover((Homes) cmbHomes.getSelectedItem(), txtSearch.getText().trim(), Integer.parseInt(yearModel.getSelectedItem().toString())), txtSearch.getText().trim(), Integer.parseInt(yearModel.getSelectedItem().toString())), false); } } }); innerPanel.add(txtSearch); JButton btnSearchGeneralReports = GUITools .createHyperlinkButton("nursingrecords.handover.searchHandovers", null, null); btnSearchGeneralReports.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { List listHandovers = HandoversTools.getBy( Integer.parseInt(yearModel.getSelectedItem().toString()), (Homes) cmbHomes.getSelectedItem()); SYSFilesTools.print(NReportTools.getReportsAndHandoversAsHTML(listHandovers, "", Integer.parseInt(yearModel.getSelectedItem().toString())), false); } }); innerPanel.add(btnSearchGeneralReports); yearCombo = new JXComboBox(yearModel); yearCombo.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { txtSearch.postActionEvent(); } }); JPanel myPanel = new JPanel(); myPanel.setOpaque(false); myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.LINE_AXIS)); myPanel.add(innerPanel); myPanel.add(yearCombo); list.add(myPanel); } cmbHomes = new JComboBox(); cmbHomes.setFont(SYSConst.ARIAL14); HomesTools.setComboBox(cmbHomes); cmbHomes.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getStateChange() != ItemEvent.SELECTED) return; reloadDisplay(); } }); list.add(cmbHomes); tbResidentFirst = GUITools.getNiceToggleButton("nursingrecords.handover.residentFirst"); SYSPropsTools.restoreState("nursingrecords.handover.tbResidentFirst", tbResidentFirst); tbResidentFirst.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { SYSPropsTools.storeState("nursingrecords.handover.tbResidentFirst", tbResidentFirst); reload(); } }); tbResidentFirst.setHorizontalAlignment(SwingConstants.LEFT); list.add(tbResidentFirst); return list; }
From source file:io.github.jeddict.jpa.modeler.source.generator.ui.GenerateCodeDialog.java
private void viewerLayerComboItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_viewerLayerComboItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { changeViewerLayer(getViewerLayer()); }//from ww w . j a v a 2 s. co m }
From source file:io.github.jeddict.jpa.modeler.source.generator.ui.GenerateCodeDialog.java
private void controllerLayerComboItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_controllerLayerComboItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { changeControllerLayer(getControllerLayer()); }//from ww w. j a va 2 s. c om }
From source file:org.nuclos.client.common.NuclosCollectController.java
protected void setupSearchToolBar() { final Action actSaveFilter = new CommonAbstractAction( getSpringLocaleDelegate().getMessage("NuclosCollectController.9", "Filter speichern"), Icons.getInstance().getIconSave16(), getSpringLocaleDelegate().getMessage( "NuclosCollectController.5", "Eingestelltes Suchkriterium als Filter speichern")) { @Override//from ww w . jav a 2 s .com public void actionPerformed(ActionEvent ev) { cmdSaveFilter(); } }; final Action actRemoveFilter = new CommonAbstractAction( getSpringLocaleDelegate().getMessage("NuclosCollectController.8", "Filter l\u00f6schen"), Icons.getInstance().getIconDelete16(), getSpringLocaleDelegate() .getMessage("NuclosCollectController.2", "Ausgew\u00e4hlten Filter l\u00f6schen")) { @Override public void actionPerformed(ActionEvent ev) { cmdRemoveFilter(); } }; //result.add(Box.createHorizontalStrut(5)); CenteringPanel cpSearchFilter = new CenteringPanel(getSearchPanel().cmbbxSearchFilter) { @Override public Dimension getMinimumSize() { return this.getCenteredComponent().getMinimumSize(); } @Override public Dimension getMaximumSize() { return this.getCenteredComponent().getPreferredSize(); } }; cpSearchFilter.setOpaque(false); ColoredLabel bl = new ColoredLabel(cpSearchFilter, getSpringLocaleDelegate().getMessage("CollectController.Search.Filter", "Filter")); bl.setName("blChooseFilter"); this.getSearchPanel().addToolBarComponent(bl); //result.add(cpSearchFilter); //result.add(Box.createHorizontalStrut(2)); this.getSearchPanel().addPopupExtraSeparator(); JMenuItem btnSaveFilter = this.getSearchPanel().addPopupExtraMenuItem(new JMenuItem(actSaveFilter)); JMenuItem btnRemoveFilter = this.getSearchPanel().addPopupExtraMenuItem(new JMenuItem(actRemoveFilter)); //final JButton btnSaveFilter = result.add(actSaveFilter); //final JButton btnRemoveFilter = result.add(actRemoveFilter); // disable the remove filter action initially: actRemoveFilter.setEnabled(false); btnSaveFilter.setName("btnSaveFilter"); btnRemoveFilter.setName("btnRemoveFilter"); getSearchPanel().cmbbxSearchFilter.setName("cmbbxSearchFilter"); getSearchPanel().cmbbxSearchFilter.setToolTipText(getSpringLocaleDelegate() .getMessage("NuclosCollectController.15", "W\u00e4hlen Sie hier einen Suchfilter aus")); getSearchPanel().cmbbxSearchFilter.addActionListener(this.alSearchFilter); // set tool tips dynamically: getSearchPanel().cmbbxSearchFilter.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList lst, Object oValue, int index, boolean bSelected, boolean bCellHasFocus) { final JComponent result = (JComponent) super.getListCellRendererComponent(lst, oValue, index, bSelected, bCellHasFocus); String sToolTip = null; if (oValue != null) { final SearchFilter filter = (SearchFilter) oValue; if (result instanceof JLabel && !StringUtils.isNullOrEmpty(filter.getLabelResourceId())) { ((JLabel) result).setText(getSpringLocaleDelegate() .getTextFallback(filter.getLabelResourceId(), filter.getName())); } if (!StringUtils.isNullOrEmpty(filter.getDescriptionResourceId())) { sToolTip = getSpringLocaleDelegate().getTextFallback(filter.getDescriptionResourceId(), filter.getDescriptionResourceId()); } else { sToolTip = filter.getDescription(); } if (filter.getOwner() != null && !(filter.getOwner().equals(Main.getInstance().getMainController().getUserName()))) { sToolTip = sToolTip + " (" + filter.getOwner() + ")"; } result.setToolTipText(sToolTip); } return result; } }); // set the tool tip for the combobox also, as the tool tip for the renderer seems to be // taken in dropped down items only: getSearchPanel().cmbbxSearchFilter.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent ev) { final boolean bSelected = (ev.getStateChange() == ItemEvent.SELECTED); boolean bRegularFilterSelected = bSelected; String sToolTip = null; if (bSelected) { final SearchFilter filter = (SearchFilter) ev.getItem(); assert filter != null; sToolTip = filter.getDescription(); LOG.debug("Filter selected: " + filter.getName()); bRegularFilterSelected = !filter.isDefaultFilter(); } getSearchPanel().cmbbxSearchFilter.setToolTipText(sToolTip); // enable/disable remove filter action - the empty filter cannot be removed: actRemoveFilter.setEnabled(bRegularFilterSelected); } }); //return result; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Drugs() { JPanel pnlContent = new JPanel(new VerticalLayout()); /***/*ww w .j ava2s .com*/ * ____ ____ _ _ _ _ _ * | _ \ _ __ _ _ __ _ / ___|___ _ __ | |_ _ __ ___ | | | | (_)___| |_ * | | | | '__| | | |/ _` | | | / _ \| '_ \| __| '__/ _ \| | | | | / __| __| * | |_| | | | |_| | (_| | | |__| (_) | | | | |_| | | (_) | | | |___| \__ \ |_ * |____/|_| \__,_|\__, | \____\___/|_| |_|\__|_| \___/|_| |_____|_|___/\__| * |___/ */ JPanel pnlDrugControl = new JPanel(new BorderLayout()); final JButton btnDrugControl = GUITools.createHyperlinkButton("opde.controlling.drugs.controllist", null, null); final JComboBox cmbStation = new JComboBox(StationTools.getAll4Combobox(false)); btnDrugControl.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { return MedStockTools.getListForMedControl((Station) cmbStation.getSelectedItem(), progressClosure); } @Override protected void done() { try { SYSFilesTools.print(get().toString(), true); } catch (ExecutionException ee) { OPDE.fatal(ee); } catch (InterruptedException ie) { // nop } OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlDrugControl.add(btnDrugControl, BorderLayout.WEST); pnlDrugControl.add(cmbStation, BorderLayout.EAST); pnlContent.add(pnlDrugControl); /*** * __ __ _ _ _ ____ _ _ _ _ _ _ * \ \ / /__(_) __ _| |__ | |_ / ___|___ _ __ | |_ _ __ ___ | | | \ | | __ _ _ __ ___ ___ | |_(_) ___ ___ * \ \ /\ / / _ \ |/ _` | '_ \| __| | / _ \| '_ \| __| '__/ _ \| | | \| |/ _` | '__/ __/ _ \| __| |/ __/ __| * \ V V / __/ | (_| | | | | |_| |__| (_) | | | | |_| | | (_) | | | |\ | (_| | | | (_| (_) | |_| | (__\__ \ * \_/\_/ \___|_|\__, |_| |_|\__|\____\___/|_| |_|\__|_| \___/|_| |_| \_|\__,_|_| \___\___/ \__|_|\___|___/ * |___/ */ JPanel pnlWeightControllNarcotics = new JPanel(new BorderLayout()); final JButton btnWeightControl = GUITools .createHyperlinkButton("opde.controlling.prescription.narcotics.weightcontrol", null, null); // final JComboBox cmbStation = new JComboBox(StationTools.getAll4Combobox(false)); btnWeightControl.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { return MedStockTools.getNarcoticsWeightList(new LocalDate().minusMonths(1), new LocalDate()); } @Override protected void done() { try { SYSFilesTools.print(get().toString(), true); } catch (ExecutionException ee) { OPDE.fatal(ee); } catch (InterruptedException ie) { // nop } OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); final JToggleButton btnNotify = new JToggleButton(SYSConst.icon22mailOFF); btnNotify.setSelectedIcon(SYSConst.icon22mailON); btnNotify.setSelected(NotificationTools.find(OPDE.getLogin().getUser(), NotificationTools.NKEY_DRUG_WEIGHT_CONTROL) != null); btnNotify.setToolTipText(SYSTools.xx("opde.notification.enable.for.this.topic")); btnNotify.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); Users user = em.merge(OPDE.getLogin().getUser()); em.lock(user, LockModeType.OPTIMISTIC_FORCE_INCREMENT); if (e.getStateChange() == ItemEvent.SELECTED) { Notification myNotification = em .merge(new Notification(NotificationTools.NKEY_DRUG_WEIGHT_CONTROL, user)); user.getNotifications().add(myNotification); } else { Notification myNotification = em.merge(NotificationTools.find(OPDE.getLogin().getUser(), NotificationTools.NKEY_DRUG_WEIGHT_CONTROL)); user.getNotifications().remove(myNotification); em.remove(myNotification); } em.getTransaction().commit(); OPDE.getLogin().setUser(user); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception ex) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(ex); } finally { em.close(); } } }); pnlWeightControllNarcotics.add(btnWeightControl, BorderLayout.WEST); pnlWeightControllNarcotics.add(btnNotify, BorderLayout.EAST); pnlContent.add(pnlWeightControllNarcotics); return pnlContent; }
From source file:com.diversityarrays.kdxplore.curate.TrialDataEditor.java
private void updateViewedTraitInstances(ItemEvent e) { TraitInstance traitInstance = (TraitInstance) e.getItem(); List<PlotOrSpecimen> selectedPlotSpecimens = new ArrayList<>(); Set<TraitInstance> selectedTraitInstances = new HashSet<>(); // works for no column movement, works for column movement collectSelectedPlotsAndColumns(selectedPlotSpecimens, selectedTraitInstances); Map<Integer, SortKey> sortKeyByColumn = new LinkedHashMap<>(); Map<SortKey, String> cnameBySortKey = new LinkedHashMap<>(); @SuppressWarnings("unchecked") TableRowSorter<CurationTableModel> rowSorter = (TableRowSorter<CurationTableModel>) curationTable .getRowSorter();/*from w ww .j ava2 s . c om*/ if (rowSorter != null) { // Make a copy because the one we get back is not modifiable! for (SortKey skey : rowSorter.getSortKeys()) { int columnIndex = skey.getColumn(); sortKeyByColumn.put(columnIndex, skey); cnameBySortKey.put(skey, curationTableModel.getColumnName(columnIndex)); } } // final Integer columnIndexForTraitInstance; boolean add = ItemEvent.SELECTED == e.getStateChange(); if (add) { curationTableModel.addTraitInstance(traitInstance); plotCellChoicesPanel.addSelectedTraitInstance(traitInstance); fieldLayoutView.addTraitInstance(traitInstance); boolean found = false; for (int index = fieldViewTraitInstanceComboBoxModel.getSize(); --index >= 0;) { if (traitInstance == fieldViewTraitInstanceComboBoxModel.getElementAt(index)) { found = true; break; } } if (!found) { addToCombo(traitInstance); } Integer columnIndexForTraitInstance = curationTableModel.getColumnIndexForTraitInstance(traitInstance); messages.println("Added " + curationTableModel.getColumnName(columnIndexForTraitInstance)); } else { selectedTraitInstances.remove(traitInstance); Integer columnIndexForTraitInstance = curationTableModel.getColumnIndexForTraitInstance(traitInstance); if (traitInstance.trait != null) { messages.println( "Removed " + traitInstance.trait.getTraitName() + " [" + columnIndexForTraitInstance + "]"); //$NON-NLS-2$ //$NON-NLS-3$ } curationTableModel.removeTraitInstance(traitInstance); plotCellChoicesPanel.removeSelectedTraitInstance(traitInstance); fieldLayoutView.removeTraitInstance(traitInstance); fieldViewTraitInstanceComboBoxModel.removeElement(traitInstance); SortKey removed = sortKeyByColumn.remove(columnIndexForTraitInstance); if (removed != null) { cnameBySortKey.remove(removed); } } if (rowSorter != null) { List<SortKey> validated = new ArrayList<>(); int nColumns = curationTableModel.getColumnCount(); for (Integer columnIndex : sortKeyByColumn.keySet()) { SortKey skey = sortKeyByColumn.get(columnIndex); if (columnIndex < nColumns) { validated.add(skey); } } if (!cnameBySortKey.isEmpty()) { String msg = cnameBySortKey.keySet().stream() .map(skey -> cnameBySortKey.get(skey) + ": " + skey.getSortOrder()) //$NON-NLS-1$ .collect(Collectors.joining("\n ", //$NON-NLS-1$ "Restoring sort order:", "")); //$NON-NLS-2$ messages.println(msg); } rowSorter.setSortKeys(validated); } if (!selectedPlotSpecimens.isEmpty()) { reapplySelection(selectedPlotSpecimens, selectedTraitInstances); } List<TraitInstance> checkedTraitInstances = null; if (curationTableModel.hasAnyTraitInstanceColumns()) { checkedTraitInstances = traitsAndInstancesPanel.getCheckedTraitInstances(); } sampleSourcesTablePanel.updateTraitInstancesCombo(checkedTraitInstances); }
From source file:org.openmicroscopy.shoola.agents.fsimporter.chooser.LocationDialog.java
/** * Listener for Group and Project JComboBox selection events * @see ItemChangeListener/*from w w w. j a v a2 s. c om*/ */ public void itemStateChanged(ItemEvent ie) { Object source = ie.getSource(); if (ie.getStateChange() == ItemEvent.SELECTED) { if (source == groupsBox) { storeCurrentSelections(); switchToSelectedGroup(); } else if (source == usersBox) { switchToSelectedUser(); } else if (source == projectsBox) { DataNode node = getSelectedItem(projectsBox); datasetsBox.setEnabled(true); newDatasetButton.setEnabled(true); if (node.isDefaultProject()) newDatasetButton.setEnabled(true); populateDatasetsBox(); } } }
From source file:zsk.JFCMainClient.java
public void itemStateChanged(ItemEvent e) { if (e.getSource() == this.saveconfigcheckbox) if (e.getStateChange() == java.awt.event.ItemEvent.SELECTED) debugoutput("saving config on exit."); else/* w w w. j a v a 2 s. c o m*/ debugoutput("don't saving config on exit."); if (e.getSource() == this.save3dcheckbox) if (e.getStateChange() == java.awt.event.ItemEvent.SELECTED) { debugoutput("trying: 3D"); output("trying: 3D"); } else { debugoutput("trying: normal 2D"); output("trying: normal 2D"); } }