void populateStartDate() throws SQLException, Exception { startDateS.removeActionListener(this); startDateS.removeAllItems(); dateRange.clear(); if (sourceTable.sourceListModel.isSelectionEmpty() == false && sourceTable.getValueAt(sourceTable.getSelectedRow(), 0).toString() != null) { Statement MySQL_Statement = dbConn.createStatement(); String getMinMaxSQL = "SELECT UNIX_TIMESTAMP(DATE_ADD(DATE(MIN(date_time)),INTERVAL 1 DAY)) AS min_date,UNIX_TIMESTAMP(DATE(MAX(date_time))) AS max_date FROM data_sa WHERE site_id = " + siteTable.getValueAt(siteTable.getSelectedRow(), 0) + " AND source_id = " + sourceTable.getValueAt(sourceTable.getSelectedRow(), 0); ResultSet minMaxResults = MySQL_Statement.executeQuery(getMinMaxSQL); if (minMaxResults.next()) { Calendar minCal = Calendar.getInstance(); minCal.setTimeZone(TimeZone.getTimeZone("GMT+10")); minCal.setTimeInMillis(minMaxResults.getLong("min_date") * 1000); long maxCal = minMaxResults.getLong("max_date") * 1000; while (minCal.getTimeInMillis() <= maxCal) { dateRange.add(minCal.getTimeInMillis()); startDateS.addItem(dateFormatter.format(minCal.getTimeInMillis())); minCal.add(Calendar.DATE, 1); } startDateS.setEnabled(true); populateEndDate(); } else { throw new Exception("ERR:NoData"); } } else { // This should never be able to happen throw new Exception("NoSource"); } startDateS.addActionListener(this); }
public void setIndexer(LibrariesIndexer indexer) { this.indexer = indexer; DropdownItem<DownloadableContribution> previouslySelectedCategory = (DropdownItem<DownloadableContribution>) categoryChooser.getSelectedItem(); DropdownItem<DownloadableContribution> previouslySelectedType = (DropdownItem<DownloadableContribution>) typeChooser.getSelectedItem(); categoryChooser.removeActionListener(categoryChooserActionListener); typeChooser.removeActionListener(typeChooserActionListener); // TODO: Remove setIndexer and make getContribModel // return a FilteredAbstractTableModel getContribModel().setIndexer(indexer); categoryFilter = null; categoryChooser.removeAllItems(); // Load categories categoryChooser.addItem(new DropdownAllItem()); Collection<String> categories = indexer.getIndex().getCategories(); for (String category : categories) { categoryChooser.addItem(new DropdownLibraryOfCategoryItem(category)); } categoryChooser.setEnabled(categoryChooser.getItemCount() > 1); categoryChooser.addActionListener(categoryChooserActionListener); if (previouslySelectedCategory != null) { categoryChooser.setSelectedItem(previouslySelectedCategory); } else { categoryChooser.setSelectedIndex(0); } typeFilter = null; typeChooser.removeAllItems(); typeChooser.addItem(new DropdownAllItem()); typeChooser.addItem(new DropdownInstalledLibraryItem(indexer.getIndex())); java.util.List<String> types = new LinkedList<String>(indexer.getIndex().getTypes()); Collections.sort(types, new LibraryTypeComparator()); for (String type : types) { typeChooser.addItem(new DropdownLibraryOfTypeItem(type)); } typeChooser.setEnabled(typeChooser.getItemCount() > 1); typeChooser.addActionListener(typeChooserActionListener); if (previouslySelectedType != null) { typeChooser.setSelectedItem(previouslySelectedType); } else { typeChooser.setSelectedIndex(0); } filterField.setEnabled(contribModel.getRowCount() > 0); // Create LibrariesInstaller tied with the provided index installer = new LibraryInstaller(indexer, platform) { @Override public void onProgress(Progress progress) { setProgress(progress); } }; }
protected void detachFrom(Component jc) { listenedTo.remove(jc); if (extListener != null && extListener.accept(jc)) { extListener.stopListeningTo(jc); } if (isProbablyAContainer(jc)) { detachFromHierarchyOf((Container) jc); } else if (jc instanceof JList) { ((JList) jc).removeListSelectionListener(this); } else if (jc instanceof JComboBox) { ((JComboBox) jc).removeActionListener(this); } else if (jc instanceof JTree) { ((JTree) jc).getSelectionModel().removeTreeSelectionListener(this); } else if (jc instanceof JToggleButton) { ((AbstractButton) jc).removeActionListener(this); } else if (jc instanceof JTextComponent) { } else if (jc instanceof JFormattedTextField) { // JFormattedTextField must be tested before JTextCompoent jc.removePropertyChangeListener("value", this); ((JTextComponent) jc).getDocument().removeDocumentListener(this); } else if (jc instanceof JColorChooser) { ((JColorChooser) jc).getSelectionModel().removeChangeListener(this); } else if (jc instanceof JSpinner) { ((JSpinner) jc).removeChangeListener(this); } else if (jc instanceof JSlider) { ((JSlider) jc).removeChangeListener(this); } else if (jc instanceof JTable) { ((JTable) jc).getSelectionModel().removeListSelectionListener(this); } if (accept(jc) && !(jc instanceof JPanel)) { jc.removePropertyChangeListener("name", this); Object key = wizardPage.getMapKeyFor(jc); if (key != null) { if (logger.isLoggable(Level.FINE)) { logger.fine( "Named component removed from hierarchy: " + // NOI18N key + ". Removing any corresponding " + // NOI18N "value from the wizard settings map."); // NOI18N } wizardPage.removeFromMap(key); } } if (logger.isLoggable(Level.FINE) && accept(jc)) { logger.fine("Stop listening to " + jc); // NOI18N } }
/** Parse clicks to cancel the recording if we get a click that's not in the JList (or ESC). */ protected boolean parseClick(AWTEvent event) { if (isFinished()) { return false; } // FIXME add key-based activation/termination? boolean consumed = true; if (combo == null) { combo = getComboBox(event); listener = new ActionListener() { public void actionPerformed(ActionEvent ev) { index = combo.getSelectedIndex(); if (!combo.isPopupVisible()) { combo.removeActionListener(listener); setFinished(true); } } }; combo.addActionListener(listener); setStatus("Waiting for selection"); } else if (event.getID() == KeyEvent.KEY_RELEASED && (((KeyEvent) event).getKeyCode() == KeyEvent.VK_SPACE || ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ENTER)) { index = combo.getSelectedIndex(); setFinished(true); } // Cancel via click somewhere else else if (event.getID() == MouseEvent.MOUSE_PRESSED && !AWT.isOnPopup((Component) event.getSource()) && combo != getComboBox(event)) { setFinished(true); consumed = false; } // Cancel via ESC key else if (event.getID() == KeyEvent.KEY_RELEASED && ((KeyEvent) event).getKeyCode() == KeyEvent.VK_ESCAPE) { setStatus("Selection canceled"); setFinished(true); } else { Log.debug("Event ignored"); } if (list == null && combo.isPopupVisible()) list = tester.findComboList(combo); if (isFinished()) { combo.removeActionListener(listener); listener = null; } return consumed; }
// WTF: this does not update packs!! // only updating info for selected pack. pulldown menus and info area! void updatePacks() { for (int i = 0; i < packPanels.size(); i++) { if (selectedPack == i && getIndex() >= 0) { ModPack pack = ModPack.getPackArray().get(getIndex()); if (pack != null) { String mods = ""; if (pack.getMods() != null) { mods += "<p>This pack contains the following mods by default:</p><ul>"; for (String name : pack.getMods()) { mods += "<li>" + name + "</li>"; } mods += "</ul>"; } packPanels.get(i).setBackground(UIManager.getColor("control").darker().darker()); packPanels.get(i).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); File tempDir = new File( OSUtils.getCacheStorageLocation(), "ModPacks" + File.separator + pack.getDir()); packInfo.setText( "<html><img src='file:///" + tempDir.getPath() + File.separator + pack.getImageName() + "' width=400 height=200></img> <br>" + pack.getInfo() + mods); packInfo.setCaretPosition(0); if (ModPack.getSelectedPack(isFTB()).getServerUrl().equals("") || ModPack.getSelectedPack(isFTB()).getServerUrl() == null) { server.setEnabled(false); } else { server.setEnabled(true); } String tempVer = Settings.getSettings().getPackVer(pack.getDir()); version.removeActionListener(al); version.removeAllItems(); version.addItem("Recommended"); if (pack.getOldVersions() != null) { for (String s : pack.getOldVersions()) { version.addItem(s); } version.setSelectedItem(tempVer); } version.addActionListener(al); } } else { packPanels.get(i).setBackground(UIManager.getColor("control")); packPanels.get(i).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } } }
/** * Constructor with a string argument that becomes part of the label of the button. * * @param settingsPanel : parent window */ public ChooseOntologyPanel( SettingsPanel settingsPanel, String bingoDir, String[] choiceArray, String choice_def) { super(); this.bingoDir = bingoDir; this.settingsPanel = settingsPanel; this.choiceArray = choiceArray; // annotationFilePath = new File(bingoDir, "bingo"); setOpaque(false); makeJComponents(); // Layout with GridLayout. setLayout(new GridLayout(1, 0)); add(choiceBox); // defaults HashSet<String> choiceSet = new HashSet<String>(); for (String s : choiceArray) { choiceSet.add(s); } if (choiceSet.contains(choice_def)) { choiceBox.setSelectedItem(choice_def); this.settingsPanel.getNamespacePanel().choiceBox.setEnabled(false); specifiedOntology = (String) choiceBox.getSelectedItem(); def = true; } else { choiceBox.removeActionListener(this); choiceBox.setEditable(true); choiceBox.setSelectedItem(choice_def); choiceBox.setEditable(false); specifiedOntology = BingoAlgorithm.CUSTOM; def = false; if (choice_def.endsWith(".obo")) { this.settingsPanel.getNamespacePanel().choiceBox.setEnabled(true); } else { this.settingsPanel.getNamespacePanel().choiceBox.setEnabled(false); } choiceBox.addActionListener(this); } }