Example usage for javax.swing DefaultListModel clear

List of usage examples for javax.swing DefaultListModel clear

Introduction

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

Prototype

public void clear() 

Source Link

Document

Removes all of the elements from this list.

Usage

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfiguratorPresenter.java

private void loadTranslations() {
    DefaultListModel translationModel = (DefaultListModel) theLstCharacterTranslations.getModel();
    translationModel.clear();
    if (userGroupData != null) {
        for (UserGroupData.CharacterTranslations translation : userGroupData.getCharacterTranslations()) {
            translationModel.addElement(translation);
        }//from   ww  w  .ja  v  a2s  .  co  m
    }
    theTxtTranslateFrom.setText("");
    theTxtTranslateTo.setText("");
    theCmbCharacterPosition.setSelectedIndex(0);
}

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfiguratorPresenter.java

private void loadSipData() throws Exception {
    if (theSipList == null) {
        return;/*w ww . j ava  2 s . c  o m*/
    }
    sipStatusCollection = SIPStatusCollection.create(sipStatusConfigFile.getAbsolutePath());
    DefaultListModel model = (DefaultListModel) theSipList.getModel();
    model.clear();
    for (SIPStatus sipStatus : sipStatusCollection) {
        model.addElement(sipStatus);
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfiguratorPresenter.java

private void loadUsers() throws Exception {
    if (theUserList == null) {
        return;/*from ww  w  . j a v  a2 s.co  m*/
    }
    userData = UserData.create(userConfigFile.getAbsolutePath(), false);
    DefaultListModel model = (DefaultListModel) theUserList.getModel();
    model.clear();
    for (IndigoUser user : userData) {
        model.addElement(user);
    }
}

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfiguratorPresenter.java

public void loadCmsMappingData() {
    MetaDataListValues currentValue = (MetaDataListValues) theDataLookupList.getSelectedValue();
    DefaultListModel model = (DefaultListModel) theCmsMappingsList.getModel();
    model.clear();
    if (currentValue != null) {
        for (String cmsMap : currentValue.getCmsMappings()) {
            model.addElement(cmsMap);//from ww w. ja  va  2 s  .  com
        }
    }
}

From source file:org.nbgames.core.PlayerManager.java

public DefaultListModel load(DefaultListModel model) {
    model.clear();
    load();/*from  w  w w  .j a  va 2  s  . c om*/

    for (Player player : mPlayers) {
        model.addElement(player);
    }

    return model;
}

From source file:org.openmrs.module.muzimabiometrics.panels.ScanFingerprint.java

private boolean SearchDevice() {
    DefaultListModel model = (DefaultListModel) scannerList.getModel();
    model.clear();
    for (NDevice device : deviceManager.getDevices()) {
        model.addElement(device);//from ww  w  . j a v a 2s  .c o m
    }
    NFingerScanner scanner = (NFingerScanner) FingersTools.getInstance().getClient().getFingerScanner();
    if ((scanner == null) && (model.getSize() > 0)) {
        scannerList.setSelectedIndex(0);
        return true;
    } else if (scanner != null) {
        scannerList.setSelectedValue(scanner, true);
        return true;
    }
    return false;
}

From source file:org.shaman.rpg.editor.dialog.DialogVisualElement.java

private void setupVisuals() {
    isInsideSetupVisuals = true;//w w w .  j a v  a 2  s .c om
    LOG.info("setup visuals");
    contentPanel.removeAll();
    commandPanels.clear();
    //load dialog
    dialog = obj.load();
    if (dialog == null) {
        contentPanel.add(new JLabel("unable to load the dialog"));
        isInsideSetupVisuals = false;
        return;
    }
    EditableProperties editableProperties = null;
    try {
        editableProperties = obj.getResourceBundle();
    } catch (IOException ex) {
        LOG.log(Level.WARNING, "unable to load properties file", ex);
    }
    //set header
    nameTextField.getDocument().removeUndoableEditListener(undoRedo);
    nameTextField.setText(dialog.getName());
    nameTextField.getDocument().addUndoableEditListener(undoRedo);
    String[] persons = dialog.getPersonList();
    @SuppressWarnings("unchecked")
    DefaultListModel<String> listModel = (DefaultListModel<String>) personsList.getModel();
    listModel.clear();
    listModel.ensureCapacity(persons.length);
    for (String p : persons) {
        listModel.addElement(p);
    }
    personsList.clearSelection();

    //set commands
    for (Command c : dialog.getCommands()) {
        CommandPanel p = null;
        if (c instanceof TextType) {
            p = new TextTypePanel();
        } else if (c instanceof StopType) {
            p = new StopTypePanel();
        } else if (c instanceof SetvarType) {
            p = new SetVarTypePanel();
        } else if (c instanceof AddvarType) {
            p = new AddVarTypePanel();
        } else if (c instanceof IfType) {
            p = new IfTypePanel();
        } else if (c instanceof LabelType) {
            p = new LabelTypePanel();
        } else if (c instanceof GotoType) {
            p = new GotoTypePanel();
        } else if (c instanceof QuestionType) {
            p = new QuestionTypePanel();
        } else {
            LOG.info("unknown command: " + c);
            continue;
        }
        p.setVisualElement(this);
        p.setDialog(dialog);
        p.setCommand(c);
        if (editableProperties != null) {
            p.updateResourceBundle(editableProperties, false);
        }
        p.setUndoRedo(undoRedo);
        contentPanel.add(p);
        commandPanels.add(p);
    }
    repaint();
    recursiveValidate(contentPanel);
    repaint();
    recursiveValidate(contentPanel);
    EventQueue.invokeLater(new Runnable() {

        @Override
        public void run() {
            recursiveValidate(contentPanel);
            contentPanel.repaint();
        }
    });
    isInsideSetupVisuals = false;
}

From source file:org.shaman.rpg.editor.dialog.DialogVisualElement.java

private void updatePersons() {
    if (isInsideSetupVisuals) {
        return;/*from   ww w .j a v a2  s  .  com*/
    }
    //Extract persons
    @SuppressWarnings("unchecked")
    final DefaultListModel<String> listModel = (DefaultListModel<String>) personsList.getModel();
    final String[] newPersons = new String[listModel.size()];
    listModel.copyInto(newPersons);
    LOG.info("settings persons to " + Arrays.toString(newPersons));
    final String[] oldPersons = dialog.getPersonList();

    //send to dialog
    dialog.setPersonList(newPersons);
    updateDialogPersons();

    // undo/redo
    undoRedo.undoableEditHappened(new UndoableEditEvent(dialog, new AbstractUndoableEdit() {

        @Override
        public void undo() throws CannotUndoException {
            super.undo();
            isInsideSetupVisuals = true;
            listModel.clear();
            listModel.ensureCapacity(oldPersons.length);
            for (String s : oldPersons) {
                listModel.addElement(s);
            }
            LOG.info("settings persons to " + Arrays.toString(oldPersons));
            dialog.setPersonList(oldPersons);
            updateDialogPersons();
            isInsideSetupVisuals = false;
        }

        @Override
        public void redo() throws CannotRedoException {
            super.redo();
            isInsideSetupVisuals = true;
            listModel.clear();
            listModel.ensureCapacity(newPersons.length);
            for (String s : newPersons) {
                listModel.addElement(s);
            }
            LOG.info("settings persons to " + Arrays.toString(newPersons));
            dialog.setPersonList(newPersons);
            updateDialogPersons();
            isInsideSetupVisuals = false;
        }

    }));
}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

public final void initIndicatorProjectManager() {
    File f = new File(
            org.yccheok.jstock.gui.Utils.getUserDataDirectory() + "indicator" + File.separator + "project.xml");
    this.alertIndicatorProjectManager = org.yccheok.jstock.gui.Utils.fromXML(IndicatorProjectManager.class, f);
    if (this.alertIndicatorProjectManager != null) {
        log.info("alertIndicatorProjectManager loaded from " + f.toString() + " successfully.");
    } else {/*from  ww w .  j a va  2  s. c  o m*/
        this.alertIndicatorProjectManager = new IndicatorProjectManager(
                org.yccheok.jstock.gui.Utils.getUserDataDirectory() + "indicator",
                OperatorIndicator.Type.AlertIndicator);
    }

    // Cleanup unused files.
    Set<String> validFileNames = new HashSet<String>();
    for (int i = 0, size = this.alertIndicatorProjectManager.getNumOfProject(); i < size; i++) {
        String PROJECTNAME = this.alertIndicatorProjectManager.getProject(i).toUpperCase();
        validFileNames.add(PROJECTNAME + ".XML");
        validFileNames.add(PROJECTNAME + "-JHOTDRAW.XML");
    }
    validFileNames.add("PROJECT.XML");

    File[] files = new File(org.yccheok.jstock.gui.Utils.getUserDataDirectory() + "indicator" + File.separator)
            .listFiles();
    for (File file : files) {
        if (validFileNames.contains(file.getName().toUpperCase())) {
            continue;
        }
        file.delete();
    }

    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            final DefaultListModel defaultListModel = (DefaultListModel) IndicatorPanel.this.jList1.getModel();
            defaultListModel.clear();
            for (int i = 0; i < IndicatorPanel.this.alertIndicatorProjectManager.getNumOfProject(); i++) {
                defaultListModel.addElement(IndicatorPanel.this.alertIndicatorProjectManager.getProject(i));
            }
            if (IndicatorPanel.this.jList1.getModel().getSize() > 0) {
                // Select first element.
                IndicatorPanel.this.jList1.setSelectedIndex(0);
            }
        }
    });
}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

public final void initModuleProjectManager() {
    final File f = new File(
            org.yccheok.jstock.gui.Utils.getUserDataDirectory() + "module" + File.separator + "project.xml");
    this.moduleIndicatorProjectManager = org.yccheok.jstock.gui.Utils.fromXML(IndicatorProjectManager.class, f);
    if (this.moduleIndicatorProjectManager != null) {
        log.info("moduleIndicatorProjectManager loaded from " + f.toString() + " successfully.");
    } else {/*w  w w. ja  v  a  2 s . com*/
        this.moduleIndicatorProjectManager = new IndicatorProjectManager(
                org.yccheok.jstock.gui.Utils.getUserDataDirectory() + "module",
                OperatorIndicator.Type.ModuleIndicator);
    }
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            final DefaultListModel defaultListModel = (DefaultListModel) jList2.getModel();
            defaultListModel.clear();
            for (int i = 0; i < IndicatorPanel.this.moduleIndicatorProjectManager.getNumOfProject(); i++) {
                defaultListModel.addElement(IndicatorPanel.this.moduleIndicatorProjectManager.getProject(i));
            }
        }
    });
}