Example usage for javax.swing DefaultListModel DefaultListModel

List of usage examples for javax.swing DefaultListModel DefaultListModel

Introduction

In this page you can find the example usage for javax.swing DefaultListModel DefaultListModel.

Prototype

DefaultListModel

Source Link

Usage

From source file:gtu._work.ui.ExecuteOpener.java

void reloadCurrentDirPropertiesList() {
    DefaultListModel model = new DefaultListModel();
    for (File file : jarPositionDir.listFiles(new FileFilter() {
        public boolean accept(File paramFile) {
            if (paramFile.getName().toLowerCase().endsWith(".properties")) {
                return true;
            }//  w  w w.j  a  va  2 s  .  co  m
            return false;
        }
    })) {
        model.addElement(file);
    }
    propertiesList.setModel(model);
}

From source file:gtu._work.ui.ExecuteOpener.java

void reloadExecListProperties(Properties prop) throws FileNotFoundException, IOException {
    DefaultListModel execListModel = new DefaultListModel();
    List<String> keys = ListUtil.getList(prop.keySet(), String.class);
    Collections.sort(keys);// w ww  . j a  v  a 2  s .  c o  m
    for (Object obj : keys) {
        execListModel.addElement((String) obj);
    }
    execList.setModel(execListModel);
}

From source file:com.openbravo.pos.sales.JRetailPanelTicket.java

public void printPartialTotals() {

    if (m_oTicket.getLinesCount() == 0) {
        m_jSubtotalEuros1.setText(null);
        m_jTaxesEuros1.setText(null);/*from  w ww.  jav  a 2 s  .  c o  m*/
        m_jTotalEuros.setText(null);
        m_jDiscount1.setText(null);
        m_jPromoDiscount.setText(null);
        m_oTicket.setBillDiscount(0);
        m_jServiceTax.setText(null);
        m_jSwachBharat.setText(null);
        m_jTaxList.setModel(new DefaultListModel());
        m_jServiceTaxLbl.setVisible(false);
        m_jSwachBharatLbl.setVisible(false);
        leastValuePromo = false;
        buyGetPromo = false;
    } else {

        try {
            if (m_oTicket.getDiscountMap() != null && m_oTicket.iscategoryDiscount()) {
                populateDiscount(m_oTicket.getDiscountMap());
            }

            populateTaxList();
        } catch (BasicException ex) {
            logger.info("exception in populateTaxList " + ex.getMessage());
            Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
        }

        m_jSubtotalEuros1.setText(m_oTicket.printSubTotalValueBeforeDiscount());
        m_jTaxesEuros1.setText(m_oTicket.printTax());
        m_jTotalEuros.setText(m_oTicket.printTotal());
        m_jDiscount1.setText(m_oTicket.printDiscount());
        m_jPromoDiscount.setText(m_oTicket.printPromoDiscount());

    }
}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

private void fillParameterSweepPage(final Model model) throws ModelInformationException {
    final List<GeneralParameter> generalParameters = model.getGeneralParameterList();
    for (final GeneralParameter gp : generalParameters) {
        if (NUMBER_OF_TURNS_LABEL_TEXT.equals(gp.getName()))
            numberOfTurnsFieldPSW.setText(gp.getValue());
        else if (NUMBER_OF_TIMESTEPS_TO_IGNORE_LABEL_TEXT.equals(gp.getName()))
            numberTimestepsIgnoredPSW.setText(gp.getValue());
    }// ww w  . j  a va 2 s .  com

    final DefaultListModel listModel = new DefaultListModel();
    final List<DefaultParameter> defaultParameters = model.getDefaultParameterList();
    ParameterTreeUtils.loadPSDefaultParameters(listModel, defaultParameters, batchParameters,
            currentModelHandler.getModelClass());
    parameterList.setModel(listModel);

    // creating combination boxes
    for (int i = 0; i < model.getCombination().size() - 1; addBox(), ++i)
        ;

    final List<Combination> sortedCombinations = new ArrayList<Combination>(model.getCombination());
    Collections.sort(sortedCombinations, new Comparator<Combination>() {
        public int compare(final Combination o1, final Combination o2) {
            return o1.getPosition().compareTo(o2.getPosition());
        }
    });

    for (int i = 0; i < sortedCombinations.size(); ++i) {
        final ParameterCombinationGUI pGUI = parameterTreeBranches.get(i);
        final DefaultTreeModel treeModel = (DefaultTreeModel) pGUI.tree.getModel();
        final DefaultMutableTreeNode combinationRoot = pGUI.combinationRoot;
        ParameterTreeUtils.loadAPSCombinationTree(treeModel, combinationRoot, batchParameters,
                currentModelHandler, sortedCombinations.get(i));

        for (int j = 0; j < pGUI.tree.getRowCount(); ++j)
            pGUI.tree.expandRow(j);
    }
}

From source file:au.org.ala.delta.intkey.Intkey.java

/**
 * Update the view of used characters//from   w  ww. j a va  2s . c o m
 */
private void updateUsedCharacters() {

    Specimen specimen = _context.getSpecimen();
    List<Character> usedCharacters = specimen.getUsedCharacters();

    List<Attribute> usedCharacterValues = new ArrayList<Attribute>();
    for (Character ch : usedCharacters) {
        usedCharacterValues.add(specimen.getAttributeForCharacter(ch));
    }

    _usedCharacterListModel = new DefaultListModel();
    for (Attribute attr : usedCharacterValues) {
        _usedCharacterListModel.addElement(attr);
    }
    _usedCharactersListCellRenderer = new AttributeCellRenderer(_context.displayNumbering(),
            _context.getDataset().getOrWord());
    _listUsedCharacters.setCellRenderer(_usedCharactersListCellRenderer);
    _listUsedCharacters.setModel(_usedCharacterListModel);

    _lblNumUsedCharacters
            .setText(MessageFormat.format(usedCharactersCaption, _usedCharacterListModel.getSize()));
}

From source file:com.openbravo.pos.sales.JRetailPanelTicket.java

public void populateTaxList() throws BasicException {
    try {/*from  ww w  . j  a  v  a2s .  com*/
        taxeslogic.calculateTaxes(m_oTicket);
    } catch (TaxesException ex) {
        logger.info("exception in populateTaxList " + ex.getMessage());
        Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
    }
    taxModel = new DefaultListModel();
    m_jTaxList.setModel(taxModel);
    empty = BorderFactory.createEmptyBorder();
    m_jTaxList.setBorder(empty);
    //added newly to calcuate taxes based on erp tax category by Shilpa
    consolidateTaxes(m_oTicket);
    int i = 0;
    for (Map.Entry<String, NameTaxMapInfo> entry : m_oTicket.getNametaxMap().entrySet()) {
        String taxName = entry.getValue().getName();
        String taxValue = String.format("%.2f", entry.getValue().getTaxValue());
        String taxEntry = "<html>" + "<style type=\\\"text/css\\\">" + "body { margin: 0px auto; }\\n" + "td { "
                + "padding: 0px;" + "margin: 0px;" + "}" + "</style>" + "<body>"
                + "   <table style=\"width:150px\">" + "      <tr bgcolor=grey>"
                + "         <td width=\"120px\" align=\"left\">" + taxName + "</td>"
                + "         <td width=\"30px\" align=\"right\">" + taxValue + "</td>" + "      </tr>      "
                + "   </table>" + "<body>" + "</html>";

        taxModel.add(i, taxEntry);
        i = i + 1;
    }

}

From source file:au.org.ala.delta.intkey.Intkey.java

/**
 * Update the view of available taxa/*w w  w.  java 2  s.com*/
 * 
 * @param availableTaxa
 *            the available taxa
 * @param taxaDifferingCharacters
 *            The differing characters for each taxa. Used when the
 *            tolerance is greater than zero to display a count of differing
 *            characters against each taxon
 */
private void updateAvailableTaxa(List<Item> availableTaxa, Map<Item, Set<Character>> taxaDifferingCharacters) {
    _availableTaxaListModel = new DefaultListModel();

    if (_context.getTolerance() > 0 && taxaDifferingCharacters != null) {
        // sort available taxa by difference count
        Collections.sort(availableTaxa, new DifferenceCountComparator(taxaDifferingCharacters));
        _availableTaxaCellRenderer = new TaxonWithDifferenceCountCellRenderer(taxaDifferingCharacters,
                _context.displayNumbering(), _context.displayComments());
    } else {
        _availableTaxaCellRenderer = new TaxonCellRenderer(_context.displayNumbering(),
                _context.displayComments());
    }

    for (Item taxon : availableTaxa) {
        _availableTaxaListModel.addElement(taxon);
    }

    _listRemainingTaxa.setCellRenderer(_availableTaxaCellRenderer);
    _listRemainingTaxa.setModel(_availableTaxaListModel);

    _lblNumRemainingTaxa.setText(MessageFormat.format(remainingTaxaCaption, _availableTaxaListModel.getSize()));

    _listRemainingTaxa.repaint();
}

From source file:au.org.ala.delta.intkey.Intkey.java

/**
 * Update the view of available taxa/*www.  ja va 2 s .c  o m*/
 * 
 * @param availableTaxa
 *            the available taxa
 * @param taxaDifferingCharacters
 *            The differing characters for each taxa. Used when the
 *            tolerance is greater than zero to display a count of differing
 *            characters against each taxon
 */
private void updateEliminatedTaxa(List<Item> eliminatedTaxa,
        Map<Item, Set<Character>> taxaDifferingCharacters) {
    // sort eliminated taxa by difference count
    Collections.sort(eliminatedTaxa, new DifferenceCountComparator(taxaDifferingCharacters));

    _eliminatedTaxaListModel = new DefaultListModel();

    for (Item taxon : eliminatedTaxa) {
        _eliminatedTaxaListModel.addElement(taxon);
    }

    _eliminatedTaxaCellRenderer = new TaxonWithDifferenceCountCellRenderer(taxaDifferingCharacters,
            _context.displayNumbering(), _context.displayComments());

    _listEliminatedTaxa.setCellRenderer(_eliminatedTaxaCellRenderer);
    _listEliminatedTaxa.setModel(_eliminatedTaxaListModel);

    _lblEliminatedTaxa.setText(MessageFormat.format(eliminatedTaxaCaption, _eliminatedTaxaListModel.getSize()));

    _listEliminatedTaxa.repaint();
}

From source file:search2go.UIFrame.java

public void identify(boolean fullProcess) {
    if ("Stop".equals(btnGTermIdent.getText())) {
        identButton.activate();//from ww  w . j  a v  a2 s. com
        try {
            if (os.isWindows()) {
                Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F");
                Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F");
                Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F");
            } else {
                Runtime.getRuntime().exec("killAll -KILL blastx");
                Runtime.getRuntime().exec("killAll -KILL blastn");
                Runtime.getRuntime().exec("killAll -KILL blastp");
            }
        } catch (IOException ex) {
            System.out.println("Error closing child processes");
        }
        prgIdentification.setIndeterminate(false);
    } else if (currentProj.checkStage(2)) {
        if (currentProj.isAvaialable()) {
            pnlChartHolder.removeAll();
            lstQueries.clearSelection();
            lstQueries.setModel(new DefaultListModel());
            txtTermInfo.setText("");

            tblGOFreq.clearSelection();
            DefaultTableModel d = new DefaultTableModel();
            d.setColumnCount(2);
            d.setColumnIdentifiers(new String[] { "GO ID", "Frequency" });
            tblGOFreq.setModel(d);

            identSequences = new ArrayList<>();

            resetIdentCount();
            for (int i = 0; i < 3; i++) {
                if (currentProj.getTargetDBString().contains(targetDBs[i])) {
                    JTextArea tempHolder = new JTextArea();
                    ProcessSequence identSequence = new ProcessSequence(currentProj,
                            new ProcessSequenceFiller(tempHolder, Integer.toString(i)) {
                                private final JTextArea sequenceOutput = tempHolder;

                                @Override
                                public void run() {
                                    new Thread(new Runnable() {
                                        @Override
                                        public void run() {
                                            for (String record : sequenceOutput.getText().split("\n")) {
                                                String name = record.split("\t")[0];
                                                GTerm nextGTerm = new GTerm(
                                                        name.substring(0, name.indexOf("[")),
                                                        name.substring(name.indexOf("[")));
                                                nextGTerm.setTopLevel(topLevels[Integer.parseInt(getNotes())]);
                                                nextGTerm.setFrequency(Integer.parseInt(record.split("\t")[1]));
                                                gTerms.addGTerm(nextGTerm);
                                            }
                                            incIdentCount();
                                        }
                                    }).start();
                                }
                            });
                    identSequences.add(identSequence);
                    Process checkFullIdent = new Process(tempHolder);
                    Path checkFullIdentPath = new Path("Processes");
                    checkFullIdentPath.append("gotFullGTerms.py");
                    checkFullIdent.setScriptCommand(checkFullIdentPath.toEscString());
                    checkFullIdent.addParameter("dir", currentProj.getPath().toEscString());
                    checkFullIdent.addParameter("db", targetDBs[i]);
                    identSequence.addProcess(checkFullIdent);
                    ProcessSequenceFiller doFullCheckOutputGetter = new ProcessSequenceFiller(tempHolder,
                            targetDBs[i]) {
                        @Override
                        public void run() {
                            if (this.getOutBox().getText().contains("false")) {
                                this.getOutBox().setText("");
                                Process mapSequenceGO = new Process(this.getOutBox());
                                Path mapSequenceGOPath = new Path("Processes");
                                mapSequenceGOPath.append("mapSequenceGO.py");
                                mapSequenceGO.setScriptCommand(mapSequenceGOPath.toEscString());
                                mapSequenceGO.addParameter("dir", currentProj.getPath().toEscString());
                                mapSequenceGO.addParameter("db", this.getNotes());
                                this.getParentSequence(0).addProcess(mapSequenceGO);

                                Process parseConverts = new Process(this.getOutBox());
                                Path parseConvertsPath = new Path("Processes");
                                parseConvertsPath.append("parseConvertedIDs.py");
                                parseConverts.setScriptCommand(parseConvertsPath.toEscString());
                                parseConverts.addParameter("dir", currentProj.getPath().toEscString());
                                parseConverts.addParameter("db", this.getNotes());
                                this.getParentSequence(0).addProcess(parseConverts);

                                identSequence.addProcess(new ProcessSequenceFiller(tempHolder) {
                                    @Override
                                    public void run() {
                                        tempHolder.setText("");
                                        try {
                                            this.finish();
                                        } catch (IOException ex) {
                                            System.out.println("Error finishing identification process filler");
                                        }
                                    }

                                });
                            }
                            this.getOutBox().setText("");
                            Process getMatchedQueryFreq = new Process(this.getOutBox());
                            Path getMatchedQueryFreqPath = new Path("Processes");
                            getMatchedQueryFreqPath.append("getMatchedQueryFreq.py");
                            getMatchedQueryFreq.setScriptCommand(getMatchedQueryFreqPath.toEscString());
                            getMatchedQueryFreq.addParameter("dir", currentProj.getPath().toEscString());
                            getMatchedQueryFreq.addParameter("db", this.getNotes());
                            this.getParentSequence(0).addProcess(getMatchedQueryFreq);
                            try {
                                this.finish();
                            } catch (IOException ex) {
                                System.out.println("Error finishing identification process filler");
                            }
                        }
                    };

                    identSequence.addProcess(doFullCheckOutputGetter);
                    try {
                        gTerms.getGTerms().clear();
                        identSequence.start();
                        identButton.setStopTargets(
                                identSequences.toArray(new ProcessSequence[identSequences.size()]));
                        if (currentProj.willDoCC())
                            currentProj.setStage(0, 2);
                        if (currentProj.willDoBP())
                            currentProj.setStage(1, 2);
                        if (currentProj.willDoBP())
                            currentProj.setStage(2, 2);
                        prgIdentification.setIndeterminate(true);
                    } catch (IOException ex) {
                        Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
            identButton.activate();
        } else
            javax.swing.JOptionPane.showMessageDialog(this,
                    "Another function is currently being performed on this project, please wait until completion or manually stop the process.");
    } else {
        System.out.println(currentProj.getStage());
        javax.swing.JOptionPane.showMessageDialog(this,
                "Mapping data unavailable. Please complete mapping step or switch to a project with completed mapping to continue.");
    }

}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

public void printPartialTotals() {

    //  setDiscountButtonEnable();
    if (m_oTicket.getLinesCount() == 0) {
        m_jSubtotalEuros1.setText(null);
        m_jTaxesEuros1.setText(null);/* w w w.j  a  va  2  s.  com*/
        m_jTotalEuros.setText(null);
        m_jDiscount1.setText(null);
        m_jPromoDiscount.setText(null);
        //          m_jBillDiscount.setText(null);
        m_oTicket.setBillDiscount(0);
        //             m_jServiceCharge.setText(null);
        m_jServiceTax.setText(null);
        //                m_jTaxList.removeAll();
        m_jTaxList.setModel(new DefaultListModel());
        m_jServiceTaxLbl.setVisible(false);
        m_jSwachBharat.setText(null);
        m_jSwachBharatLbl.setVisible(false);
    } else {

        //                calculateServiceCharge();
        try {
            System.out.println("m_oTicket.iscategoryDiscount()" + m_oTicket.iscategoryDiscount());
            if (m_oTicket.getDiscountMap() != null && m_oTicket.iscategoryDiscount()) {
                populateDiscount(m_oTicket.getDiscountMap());
            }
            // populateServiceChargeList();
            // populateServiceTaxList();
            populateTaxList();
            // populateSwachBharatTaxList();
        } catch (BasicException ex) {
            logger.info("exception in populateTaxList " + ex.getMessage());
            Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
        }
        System.out.println("m_oTicket.printSubTotalValue()---" + m_oTicket.printSubTotalValue());
        //m_jSubtotalEuros1.setText(m_oTicket.printSubTotalValue());
        m_jSubtotalEuros1.setText(m_oTicket.printSubTotalValueBeforeDiscount());
        m_jTaxesEuros1.setText(m_oTicket.printTax());
        m_jTotalEuros.setText(m_oTicket.printTakeAwayTotal());
        m_jDiscount1.setText(m_oTicket.printDiscount());
        m_jPromoDiscount.setText(m_oTicket.printPromoDiscount());
        //  m_jDiscount1.setText(m_oTicket.printLineDiscount());
        //                if(m_oTicket.printServiceCharge()!=null){
        //                    //jLabel13.setVisible(true);
        //                    m_jServiceCharge.setText("0.00");
        //                }
        if (m_oTicket.printServiceTax() != null) {
            //   m_jServiceTaxLbl.setVisible(true);
            //   m_jServiceTax.setText(m_oTicket.printServiceTax());
        }
        if (m_oTicket.printSwachBharatTax() != null) {
            //    m_jSwachBharatLbl.setVisible(true);
            //  m_jSwachBharat.setText(m_oTicket.printSwachBharatTax());
        }

    }

    setTenderAmount();
}