List of usage examples for javax.swing.event ListSelectionEvent getValueIsAdjusting
public boolean getValueIsAdjusting()
From source file:net.sf.vfsjfilechooser.plaf.metal.MetalVFSFileChooserUI.java
/** * @param e//from w w w. j a v a 2 s . c o m */ public void valueChanged(ListSelectionEvent e) { VFSJFileChooser fc = getFileChooser(); FileObject f = fc.getSelectedFile(); if (!e.getValueIsAdjusting() && (f != null) && !getFileChooser().isTraversable(f)) { setFileName(fileNameString(f)); } }
From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java
/** * @param e/*from ww w . j av a 2 s . co m*/ */ public void valueChanged(ListSelectionEvent e) { VFSJFileChooser fc = getFileChooser(); FileObject f = fc.getSelectedFileObject(); if (!e.getValueIsAdjusting() && (f != null) && !getFileChooser().isTraversable(f)) { setFileName(fileNameString(f)); } }
From source file:edu.ku.brc.specify.utilapps.RegisterApp.java
/** * @return/*from w w w. j a v a2 s . c om*/ */ private JPanel getStatsPane(final String chartPrefixTitle, final Collection<RegProcEntry> entries, final String tableName) { CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "f:p:g")); final Hashtable<String, String> keyDescPairsHash = rp.getAllDescPairsHash(); final Hashtable<String, String> desc2KeyPairsHash = new Hashtable<String, String>(); for (String key : keyDescPairsHash.keySet()) { desc2KeyPairsHash.put(keyDescPairsHash.get(key), key); } Vector<String> keywords = new Vector<String>(); for (String keyword : getKeyWordsList(entries)) { if (keyword.endsWith("_name") || keyword.endsWith("_type") || keyword.endsWith("ISA_Number") || keyword.endsWith("reg_isa")) { //keywords.add(keyword); } else { String desc = keyDescPairsHash.get(keyword); //System.out.println("["+keyword+"]->["+desc+"]"); if (desc != null) { keywords.add(desc); } else { System.out.println("Desc for keyword[" + keyword + "] is null."); } } } Vector<Object[]> rvList = BasicSQLUtils .query("SELECT DISTINCT(Name) FROM registeritem WHERE SUBSTRING(Name, 1, 4) = 'num_'"); for (Object[] array : rvList) { keywords.add((String) array[0]); } Collections.sort(keywords); final JList list = new JList(keywords); pb.add(UIHelper.createScrollPane(list), cc.xy(1, 1)); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { String statName = (String) list.getSelectedValue(); if (desc2KeyPairsHash.get(statName) != null) { statName = desc2KeyPairsHash.get(statName); } DateType dateType = convertDateType(statName); if (dateType == DateType.None) { Vector<Pair<String, Integer>> values; if (statName.startsWith("num_")) { values = getCollNumValuesFromList(statName); Hashtable<String, Boolean> hash = new Hashtable<String, Boolean>(); for (Pair<String, Integer> p : values) { if (hash.get(p.first) == null) { hash.put(p.first, true); } else { int i = 0; String name = p.first; while (hash.get(p.first) != null) { p.first = name + " _" + i; i++; } hash.put(p.first, true); } //p.first += "(" + p.second.toString() + ")"; } } else { values = getCollValuesFromList(statName); } Collections.sort(values, countComparator); Vector<Pair<String, Integer>> top10Values = new Vector<Pair<String, Integer>>(); for (int i = 1; i < Math.min(11, values.size()); i++) { top10Values.insertElementAt(values.get(values.size() - i), 0); } createBarChart(chartPrefixTitle + " " + statName, statName, top10Values); } else { String desc = getByDateDesc(dateType); Vector<Pair<String, Integer>> values = tableName.equals("track") ? getDateValuesFromListByTable(dateType, tableName) : getDateValuesFromList(dateType); Collections.sort(values, titleComparator); createBarChart(chartPrefixTitle + " " + desc, desc, values); } } } }); return pb.getPanel(); }
From source file:edu.ku.brc.specify.utilapps.RegisterApp.java
/** * /*from w w w .j a va2 s . c o m*/ */ @SuppressWarnings("unchecked") protected void doSetVersion() { CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,2px,f:p:g")); Vector<String> versionsList = new Vector<String>(); Hashtable<String, String> verToDateHash = new Hashtable<String, String>(); try { SimpleDateFormat mmddyyyy = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat yyyymmdd = new SimpleDateFormat("yyyy/MM/dd"); List<String> lines = FileUtils.readLines(rp.getDataFromWeb( UIRegistry.getResourceString("CGI_BASE_URL") + "/specifydownloads/specify6/alpha/versions.txt", false)); for (String line : lines) { String[] toks = line.split(","); if (toks.length > 2) { String ver = StringUtils.remove(toks[1].trim(), "Alpha "); versionsList.insertElementAt(ver, 0); String dateStr = toks[2].trim(); dateStr = StringUtils.replace(dateStr, ".", "/"); try { Date date = mmddyyyy.parse(dateStr); verToDateHash.put(ver, yyyymmdd.format(date)); } catch (Exception ex) { } } } versionsList.insertElementAt("Clear", 0); } catch (IOException ex) { ex.printStackTrace(); } final JList list = new JList(versionsList); final CustomDialog dlg = new CustomDialog(null, "Set Version", true, pb.getPanel()); pb.add(UIHelper.createLabel("Versions", SwingConstants.CENTER), cc.xy(1, 1)); pb.add(UIHelper.createScrollPane(list), cc.xy(1, 3)); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { dlg.getOkBtn().setEnabled(list.getSelectedIndex() > -1); } } }); list.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if (e.getClickCount() == 2) { dlg.getOkBtn().doClick(); } } }); pb.setDefaultDialogBorder(); dlg.createUI(); dlg.getOkBtn().setEnabled(false); dlg.setVisible(true); if (!dlg.isCancelled()) { int inx = list.getSelectedIndex(); String version = (String) list.getSelectedValue(); if (version.equals("Clear")) { rp.setVersionDates(null, null, null); frame.setTitle(title); } else { String prevVersion = inx == list.getModel().getSize() - 1 ? null : (String) list.getModel().getElementAt(inx + 1); rp.setVersionDates(version, prevVersion, verToDateHash); frame.setTitle(title + " for " + version); } /*try { rp.process(doLocal ? new File("reg.dat") : rp.getDataFromWeb("SpReg.REGISTER_URL", true)); rp.processTracks(doLocal ? new File("track.dat") : rp.getDataFromWeb("StatsTrackerTask.URL", true)); rp.mergeStats(); } catch (IOException ex) { ex.printStackTrace(); }*/ } }
From source file:com.aw.swing.mvp.binding.component.BndSJTable.java
/** * Register a selection listener to the JTable related to this class * * @param rowSelectionListener that will be called when the selection of the JTable changes *///from w w w . j a va2 s. c om public void registerRowSelectionListener(final RowSelectionListener rowSelectionListener) { ListSelectionModel rowSM = jTable.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { //Ignore extra messages. if (e.getValueIsAdjusting()) return; ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { logger.debug("No rows are selected."); rowSelectionListener.onClearSelectedRow(); } else { int selectedRowIndex = lsm.getMinSelectionIndex(); logger.debug("Row " + selectedRowIndex + " is now selected."); Object selectedRow = getSelectedRow(); rowSelectionListener.onSelectedRow(selectedRowIndex, selectedRow); } } }); }
From source file:edu.ku.brc.specify.datamodel.busrules.BaseTreeBusRules.java
@Override public void initialize(Viewable viewableArg) { super.initialize(viewableArg); GetSetValueIFace parentField = (GetSetValueIFace) formViewObj.getControlByName("parent"); Component comp = formViewObj.getControlByName("definitionItem"); if (comp instanceof ValComboBox) { final ValComboBox rankComboBox = (ValComboBox) comp; final JCheckBox acceptedCheckBox = (JCheckBox) formViewObj.getControlByName("isAccepted"); Component apComp = formViewObj.getControlByName("acceptedParent"); final ValComboBoxFromQuery acceptedParentWidget = apComp instanceof ValComboBoxFromQuery ? (ValComboBoxFromQuery) apComp : null;/*from w w w . ja va 2 s . c o m*/ if (parentField instanceof ValComboBoxFromQuery) { final ValComboBoxFromQuery parentCBX = (ValComboBoxFromQuery) parentField; if (parentCBX != null && rankComboBox != null) { parentCBX.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e == null || !e.getValueIsAdjusting()) { parentChanged(formViewObj, parentCBX, rankComboBox, acceptedCheckBox, acceptedParentWidget); } } }); rankComboBox.getComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { rankChanged(formViewObj, parentCBX, rankComboBox, acceptedCheckBox, acceptedParentWidget); } }); } } if (acceptedCheckBox != null && acceptedParentWidget != null) { acceptedCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (acceptedCheckBox.isSelected()) { acceptedParentWidget.setValue(null, null); acceptedParentWidget.setChanged(true); // This should be done automatically acceptedParentWidget.setEnabled(false); } else { acceptedParentWidget.setEnabled(true); } } }); } } }
From source file:edu.ku.brc.specify.config.init.secwiz.UserPanel.java
/** * /*from www. ja v a 2 s . c o m*/ */ protected void createUI() { dbList = new JList(new DefaultListModel()); otherDBList = new JList(new DefaultListModel()); userModel = new UserTableModel(null); userTable = new JTable(userModel); CellConstraints cc = new CellConstraints(); saveBtn = UIHelper.createButton("Save"); mkKeysBtn = UIHelper.createButton("Make Keys"); copyKeyBtn = UIHelper.createButton("Copy Master Key"); sendKeysBtn = UIHelper.createButton("Send Keys"); showKeysBtn = UIHelper.createButton("Show Summary"); printKeysBtn = UIHelper.createButton("Print"); btns = new JButton[] { saveBtn, sendKeysBtn, copyKeyBtn, showKeysBtn, printKeysBtn }; String colDef = UIHelper.createDuplicateJGoodiesDef("p", "8px", btns.length); PanelBuilder btnPB = new PanelBuilder(new FormLayout("f:p:g," + colDef, "p")); int x = 2; for (JButton b : btns) { btnPB.add(b, cc.xy(x, 1)); x += 2; } saveBtn.setEnabled(false); copyKeyBtn.setEnabled(false); label = UIHelper.createLabel("", SwingConstants.CENTER); gainAccessBtn = UIHelper.createIconBtn("Unmap", "", null); loseAccessBtn = UIHelper.createIconBtn("Map", "", null); PanelBuilder bpb = new PanelBuilder(new FormLayout("p", "f:p:g,p,8px,p,f:p:g")); bpb.add(gainAccessBtn, cc.xy(1, 2)); bpb.add(loseAccessBtn, cc.xy(1, 4)); PanelBuilder tpb = new PanelBuilder(new FormLayout("f:p:g,10px,p,10px,f:p:g", "p,4px,f:p:g")); tpb.add(UIHelper.createI18NLabel("MSTR_HAS_PERM", SwingConstants.CENTER), cc.xy(1, 1)); tpb.add(otherDBLbl = UIHelper.createI18NLabel("MSTR_HAS_NOPERM", SwingConstants.CENTER), cc.xy(5, 1)); tpb.add(dbScrollPane = UIHelper.createScrollPane(dbList), cc.xy(1, 3)); tpb.add(bpb.getPanel(), cc.xy(3, 3)); tpb.add(odbScrollPane = UIHelper.createScrollPane(otherDBList), cc.xy(5, 3)); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,p", "f:p:g,20px,p,8px,p,4px,f:p:g,4px,p,20px,p"), this); sendKeysBtn.setVisible(false); int y = 1; pb.add(tpb.getPanel(), cc.xyw(1, y, 2)); y += 2; y += 2; pb.add(label, cc.xyw(1, y, 2)); y += 2; pb.add(userScrollPane = UIHelper.createScrollPane(userTable), cc.xyw(1, y, 2)); y += 2; pb.add(btnPB.getPanel(), cc.xy(2, y)); y += 2; pb.addSeparator("", cc.xyw(1, y, 2)); y += 2; dbList.setVisibleRowCount(8); otherDBList.setVisibleRowCount(8); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { Dimension size = userTable.getPreferredScrollableViewportSize(); size.height = 10 * userTable.getRowHeight(); userTable.setPreferredScrollableViewportSize(size); } }); updateBtnUI(false); dbList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { loadData(false); gainAccessBtn.setEnabled(otherDBList.getSelectedIndex() > -1); loseAccessBtn.setEnabled(dbList.getSelectedIndex() > -1); } } }); userTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { doUserSelected(); } } }); saveBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveUserData(); } }); sendKeysBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { sendKeys(); } }); mkKeysBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { makeKeys(); } }); copyKeyBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int inx = userTable.getSelectedRow(); if (inx > -1) { String masterKey = userModel.getUserData().get(inx).getMasterKey(); UIHelper.setTextToClipboard(masterKey); } } }); showKeysBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { displayData(); } }); printKeysBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { printUserData(); } }); gainAccessBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changeMasterAccess(true); } }); loseAccessBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changeMasterAccess(false); } }); otherDBList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { otherDBName = (String) otherDBList.getSelectedValue(); gainAccessBtn.setEnabled(otherDBList.getSelectedIndex() > -1); loseAccessBtn.setEnabled(dbList.getSelectedIndex() > -1); } } }); }
From source file:de.tor.tribes.ui.views.DSWorkbenchReTimerFrame.java
@Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { int selectionCount = jResultTable.getSelectedRowCount(); if (selectionCount != 0) { showInfo(selectionCount + ((selectionCount == 1) ? " Angriff gewhlt" : " Angriffe gewhlt")); }//from w ww.j av a 2 s . c om } }
From source file:it.cnr.icar.eric.client.ui.swing.RegistryObjectsTable.java
@SuppressWarnings("unchecked") private void addRenderers() { try {//from w w w. ja v a2s . c o m setDefaultRenderer(Class.forName("java.lang.Object"), new JBDefaultTableCellRenderer()); setDefaultRenderer(Class.forName("java.util.Collection"), new CollectionRenderer()); final JList<Object> list = new JList<Object>(); list.setVisibleRowCount(3); list.setOpaque(true); list.setCellRenderer(new ListDefaultRenderer()); list.addListSelectionListener(new ListSelectionListener() { @SuppressWarnings({ "static-access", "unused" }) public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { Object obj = list.getSelectedValue(); obj = RegistryObjectsTable.this.convertValue(obj); if (obj instanceof URL) { HyperLinker.displayURL(obj.toString()); } else if (obj instanceof String) { //Check if URL is valid URL _url = null; try { _url = new URL(obj.toString()); HyperLinker.displayURL(obj.toString()); } catch (MalformedURLException exc) { //No need to do anything. It is normal for text to not be a URL _url = null; } } } } }); JScrollPane listPane = new JScrollPane(list); setDefaultEditor(Class.forName("java.util.Collection"), new JBDefaultCellEditor(listPane)); HyperLinkLabel hyperLinkLabel = new HyperLinkLabel(); hyperLinkLabel.setHorizontalAlignment(SwingConstants.TRAILING); setDefaultEditor(Class.forName("java.lang.Object"), new JBDefaultCellEditor(hyperLinkLabel)); } catch (ClassNotFoundException e) { return; } }
From source file:edu.ku.brc.af.ui.db.TextFieldWithQuery.java
/** * * @param advanceFocus// w w w .j a v a2s . c o m */ protected void showDialog(final int advanceFocus) { final Vector<Integer> idListLocal = (Vector<Integer>) idList.clone(); final Vector<String> listLocal = (Vector<String>) list.clone(); final String enteredText = StringUtils.isEmpty(prevEnteredText) ? cachedPrevText : prevEnteredText; DefaultListModel<String> model = new DefaultListModel<String>(); if (doAddAddItem) { model.addElement(UIRegistry.getResourceString("TFWQ_ADD_LABEL")); //$NON-NLS-1$ } for (String val : list) { model.addElement(val); } final JList<String> listBox = new JList<String>(model); JPanel panel = new JPanel(new BorderLayout()); panel.add(createLabel(UIRegistry.getResourceString("TFWQ_CHOOSE_LABEL"), SwingConstants.CENTER), //$NON-NLS-1$ BorderLayout.NORTH); panel.add(UIHelper.createScrollPane(listBox, true), BorderLayout.CENTER); panel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); // Had to do inner class in order to get it to select an item // before being shown class PopUpDialog extends CustomDialog { protected JList<String> pListBox; public PopUpDialog(final Frame frame, final boolean isModal, final Component contentPanel, JList<String> pListBoxArg) throws HeadlessException { super(frame, UIRegistry.getResourceString("TFWQ_CHOOSE_TITLE"), isModal, contentPanel); //$NON-NLS-1$ this.pListBox = pListBoxArg; initialize(); } public PopUpDialog(final Dialog dialog, final boolean isModal, final Component contentPanel, JList<String> pListBoxArg) throws HeadlessException { super(dialog, UIRegistry.getResourceString("TFWQ_CHOOSE_TITLE"), isModal, OK_BTN | CANCEL_BTN, //$NON-NLS-1$ contentPanel); this.pListBox = pListBoxArg; initialize(); } /** * */ protected void initialize() { pListBox.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (okBtn != null && pListBox != null) { okBtn.setEnabled(listBox.getSelectedIndex() != -1); } } } }); pListBox.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if (e.getClickCount() == 2) { okBtn.setEnabled(true); okBtn.doClick(); } } }); } @Override public void setVisible(final boolean visible) { if (visible) { listBox.setSelectedIndex(doAddAddItem ? 1 : 0); } super.setVisible(visible); } } hasNewText = false; Window mostRecent = UIRegistry.getMostRecentWindow(); CustomDialog dlg; if (mostRecent instanceof Dialog) { dlg = new PopUpDialog((Dialog) UIRegistry.getMostRecentWindow(), true, panel, listBox); } else { dlg = new PopUpDialog((Frame) UIRegistry.getMostRecentWindow(), true, panel, listBox); } dlg.setVisible(true); if (!dlg.isCancelled()) { int inx = listBox.getSelectedIndex(); boolean isDoingAdd = inx == 0 && doAddAddItem; inx = doAddAddItem ? inx - 1 : inx; if (!isDoingAdd && inx < idListLocal.size()) { selectedId = idListLocal.get(inx); setText(listLocal.get(inx)); } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { transferFocus(advanceFocus); notifyListenersOfChange(isDoingAdd ? new AddItemEvent(enteredText) : listBox); } }); } else { setText(""); //$NON-NLS-1$ } }