List of usage examples for javax.swing DefaultListModel clear
public void clear()
From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java
/** * //from w w w .j av a 2s . c o m */ protected void levelSelected() { selectedViewSet = null; selectedView = null; selectedViewDef = null; selectedAltView = null; ((DefaultTreeModel) tree.getModel()).setRoot(null); DefaultListModel model = (DefaultListModel) viewsList.getModel(); model.clear(); model = (DefaultListModel) altViewsList.getModel(); model.clear(); model = (DefaultListModel) viewSetsList.getModel(); model.clear(); viewSetVector.clear(); DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession(); for (SpAppResourceDir dir : ((SpecifyAppContextMgr) AppContextMgr.getInstance()).getSpAppResourceList()) { if (dir.getSpAppResourceDirId() != null) { session.attach(dir); } //for (SpViewSetObj viewSetObj : dir.getSpViewSets()) //{ //model.addElement(viewSetObj.getName()); for (SpViewSetObj vso : dir.getSpViewSets()) { try { Element root = XMLHelper.readStrToDOM4J(vso.getDataAsString()); ViewSet viewSet = new ViewSet(root, false); viewSetVector.add(viewSet); //System.out.println(viewSet); model.addElement(viewSet.getName()); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ViewSetSelectorPanel.class, ex); //log.error(vso.getName()); //log.error(ex); ex.printStackTrace(); throw new RuntimeException(ex); } } //} } session.close(); }
From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java
protected void viewSetSelected() { selectedViewSet = null;/*from ww w .ja v a2s . com*/ selectedView = null; selectedViewDef = null; selectedAltView = null; ((DefaultTreeModel) tree.getModel()).setRoot(null); DefaultListModel model; model = (DefaultListModel) altViewsList.getModel(); model.clear(); model = (DefaultListModel) viewDefsList.getModel(); model.clear(); model = (DefaultListModel) viewsList.getModel(); model.clear(); int inx = viewSetsList.getSelectedIndex(); if (inx > -1) { selectedViewSet = (ViewSet) viewSetVector.get(inx); viewControlPanel.getAddBtn().setEnabled(true); viewDefControlPanel.getAddBtn().setEnabled(true); Vector<String> names = new Vector<String>(selectedViewSet.getViews().keySet()); Collections.sort(names); for (String viewName : names) { model.addElement(viewName); } model = (DefaultListModel) viewDefsList.getModel(); names.clear(); names.addAll(selectedViewSet.getViewDefs().keySet()); Collections.sort(names); for (String viewDefName : names) { model.addElement(viewDefName); } } else { viewControlPanel.getAddBtn().setEnabled(false); viewDefControlPanel.getAddBtn().setEnabled(false); } }
From source file:edu.ku.brc.specify.tools.StrLocalizerApp.java
/** * @param newSrc/*from w w w. j a v a2 s .c o m*/ */ protected void newSrcFile(final StrLocaleFile newSrc) { termList.clearSelection(); newTermList.clearSelection(); srcFile = newSrc; // re-create and reload the dest file to clear unsaved changes and/or states int destInx = getLocaleFileInxBySrcPath(destFiles, srcFile.getPath()); StrLocaleFile oldDest = destFiles.get(destInx); destFile = new StrLocaleFile(oldDest.getPath(), oldDest.getSrcPath(), true); destFiles.set(destInx, destFile); newKeyList.clear(); mergeToSrc(srcFile, destFile); ItemModel termsModel = new ItemModel(srcFile); termList.setModel(termsModel); DefaultListModel itemModel = new DefaultListModel(); itemModel.clear(); for (String str : newKeyList) { itemModel.addElement(str); } newTermList.setModel(itemModel); rsController.setLength(srcFile.getNumberOfKeys()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { fileLbl.setText(destFile.getPath()); } }); searchable = new LocalizerSearchHelper(baseDir, "props-index"); searchable.indexProps(srcFile.getItems()); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.TemplateEditor.java
/** * Fill in the JList's model from the list of fields. * @param tableInfo the table who's list we should use *//*www. j a va 2 s. co m*/ protected void fillFieldList(final TableInfo tableInfo) { DefaultListModel model = (DefaultListModel) fieldList.getModel(); model.clear(); fieldList.clearSelection(); if (tableInfo != null) { for (FieldInfo fi : tableInfo.getFieldItems()) { model.addElement(fi); } } }
From source file:com.xyphos.vmtgen.GUI.java
private void showTextureFiles() { DefaultListModel model = (DefaultListModel) lstFiles.getModel(); model.clear(); String root = txtRootFolder.getText(); String work = txtWorkFolder.getText(); if (root.isEmpty() || work.isEmpty()) { return;//from w w w . ja va 2s . co m } basePath = work.replace(root, ""); File dir = new File(work); String full, name, ext; if (chkOnlyMissing.isSelected()) { List<String> fileVTF = new ArrayList<>(); List<String> fileVMT = new ArrayList<>(); for (File file : dir.listFiles()) { if (file.isFile()) { full = file.getName(); //name = FilenameUtils.getBaseName( full ); ext = FilenameUtils.getExtension(full); if (ext.equalsIgnoreCase("vtf")) { fileVTF.add(full); } else if (ext.equalsIgnoreCase("vmt")) { fileVMT.add(full); } } } String baseName; Iterator<String> itr; boolean matched; for (String file : fileVTF) { baseName = FilenameUtils.getBaseName(file); itr = fileVMT.iterator(); matched = false; while (itr.hasNext()) { if (FilenameUtils.getBaseName(itr.next()).equalsIgnoreCase(baseName)) { matched = true; break; } } if (!matched) { model.addElement(file); } } } else { for (File file : dir.listFiles()) { name = file.getName(); ext = FilenameUtils.getExtension(name); if (file.isFile() && ext.equalsIgnoreCase("vtf")) { model.addElement(name); } } } }
From source file:edu.ku.brc.specify.utilapps.RegisterApp.java
/** * @param catName// w ww.j av a 2 s . com */ protected void fillUsageItemsList(final String catName) { String sql = "SELECT Name, Total FROM (SELECT Name, SUM(CountAmt) as Total FROM trackitem WHERE CountAmt < 100000 AND SUBSTRING(Name, 1, 8) = 'Usage_" + catName + "' GROUP BY Name) AS T1 ORDER BY Total"; System.out.println(sql); Vector<Object[]> rows = BasicSQLUtils.query(sql); DefaultListModel model = (DefaultListModel) trackItemsList.getModel(); if (rows != null && rows.size() > 0) { boolean isCatOK = catName.length() == 2; boolean isDataEntry = catName.equals("DE"); boolean isDatabase = catName.equals("DB"); Hashtable<String, Boolean> clsHash = new Hashtable<String, Boolean>(); Vector<Pair<String, Integer>> values = new Vector<Pair<String, Integer>>(); int total = 0; for (Object[] colData : rows) { String name = (String) colData[0]; int val = ((BigDecimal) colData[1]).intValue(); if (name.startsWith("Usage_")) { name = name.substring(6); } String str; if (isCatOK && name.charAt(2) == '_') { str = name.substring(catName.length() + 1); /*if (str.startsWith(catName) && str.charAt(2) == '_') { str = str.substring(catName.length()+1); }*/ if (str.startsWith("VIEW_")) { str = str.substring(5); } if (isDataEntry) { String clsName = str; if (clsName.endsWith("_RS")) { clsName = clsName.substring(0, clsName.length() - 3); } clsHash.put(clsName, true); } else if (isDatabase) { int inx = str.lastIndexOf('_'); String clsName = str.substring(inx + 1); clsHash.put(clsName, true); } } else { str = name; } values.add(new Pair<String, Integer>(str, val)); total += val; } Collections.sort(values, countComparator); createBarChart(trackDescHash.get(catName), "Actions", values); // Fill Model model.clear(); sql = "SELECT DISTINCT(Name) FROM trackitem WHERE SUBSTRING(Name, 1, 8) = 'Usage_" + catName + "' ORDER BY Name"; rows = BasicSQLUtils.query(sql); if (rows != null && rows.size() > 0) { for (Object[] colData : rows) { model.addElement(colData[0]); } } if (clsHash.size() > 0) { showClassList(clsHash); } else if (classFrame != null && classFrame.isVisible()) { classFrame.setVisible(false); } } else { model.clear(); if (chartFrame != null && chartFrame.isVisible()) { chartFrame.setVisible(false); } } }
From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java
/** * @param parentQRI//from www. j ava2 s . c om * @param tableTree * @param model */ protected void createNewList(final TableQRI tblQRI, final DefaultListModel model) { model.clear(); if (tblQRI != null) { Vector<BaseQRI> sortList = new Vector<BaseQRI>(); for (int f = 0; f < tblQRI.getFields(); f++) { if (!tblQRI.getField(f).isFieldHidden()) { sortList.add(tblQRI.getField(f)); } } for (int k = 0; k < tblQRI.getTableTree().getKids(); k++) { boolean addIt; TableTree kidK = tblQRI.getTableTree().getKid(k); if (kidK.isAlias()) { // if (!fixAliases(kidK, tableTreeHash)) // { // addIt = false; // } // else // { // addIt = tblIsDisplayable(kidK, tableTreeHash.get(kidK.getName()) // .getTableInfo()); // } addIt = tblIsDisplayable(kidK, tableTreeHash.get(kidK.getName()).getTableInfo()) && fixAliases(kidK, tableTreeHash); } else { addIt = !kidK.getTableInfo().isHidden() && tblIsDisplayable(kidK, kidK.getTableInfo()); } if (addIt) { if (kidK.getTableQRI().getRelationship() == null || !kidK.getTableQRI().getRelationship().isHidden()) { sortList.add(tblQRI.getTableTree().getKid(k).getTableQRI()); } } } Collections.sort(sortList); checkFldUsage(tblQRI.getTableTree(), sortList); for (QryListRendererIFace qri : sortList) { model.addElement(qri); } } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
private void loadProducersList() { try {//w ww . j av a2 s .c o m LOG.debug("loadProducersList, start"); DefaultListModel model; if (theProducerList.getModel() instanceof DefaultListModel) { model = (DefaultListModel) theProducerList.getModel(); model.clear(); } else { model = new DefaultListModel(); } LOG.debug("loadProducersList, Before create deposit"); IDeposit deposit = applicationProperties.getApplicationData().getDeposit(); producers = deposit.getProducers(applicationProperties.getLoggedOnUser()); LOG.debug("loadProducersList, After get list"); for (Producer data : producers) { model.addElement(data); } theProducerList.setModel(model); theProducerList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { lstProducersValueChanged(evt); } }); theProducerList.repaint(); LOG.debug("loadProducersList, end"); } catch (Exception ex) { manualDepositFrame.showError("Error loading producers", "Unable to load producer list", ex); reportException(ex); } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
public void loadMaterialFlowList(String producerID) throws Exception { LOG.debug("loadMaterialFlowList, start"); DefaultListModel model; if (theMaterialFlowList.getModel() instanceof DefaultListModel) { model = (DefaultListModel) theMaterialFlowList.getModel(); model.clear(); } else {/* w w w . j a v a 2 s . c o m*/ model = new DefaultListModel(); } LOG.debug("loadMaterialFlowList, Before create deposit"); IDeposit deposit = applicationProperties.getApplicationData().getDeposit(); LOG.debug("loadMaterialFlowList, After create deposit, before get list"); ArrayList<MaterialFlow> flows = deposit.getMaterialFlows(producerID); LOG.debug("loadProducersList, After get list"); for (MaterialFlow data : flows) { model.addElement(data); } theMaterialFlowList.setModel(model); LOG.debug("loadMaterialFlowList, start"); }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
public void filterProducerList(String theFilter) { if (producers == null || producers.isEmpty()) return;/*from w ww .j av a 2 s .co m*/ DefaultListModel model = (DefaultListModel) theProducerList.getModel(); // Producer selectedProducer = null; // if (theProducerList.getSelectedValue() != null) { // selectedProducer = (Producer) theProducerList.getSelectedValue(); // } model.clear(); for (Producer data : producers) { if (data.getDescription().toLowerCase().contains(theFilter.toLowerCase())) { model.addElement(data); } } // if (selectedProducer != null) { // theProducerList.setSelectedValue(selectedProducer, true); // } // // theProducerList.setSelectedIndex(-1); }