javax.swing.DefaultListModel#clear ( )源码实例Demo

下面列出了javax.swing.DefaultListModel#clear ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MeteoInfo   文件: FrmJoinNCFiles.java
private void setDataFolder(File path) {
    if (!path.isDirectory())
        return;
    
    this.jLabel_DataFolder.setText(path.getAbsolutePath());
    DefaultListModel listModel_all = (DefaultListModel)this.jList_AllFiles.getModel();
    DefaultListModel listModel_sel = (DefaultListModel)this.jList_SelectedFiles.getModel();
    listModel_all.clear();
    listModel_sel.clear();
    File[] files = path.listFiles();
    Arrays.sort(files);
    for (File file : files) {
        if (file.isFile()) {
            String name = file.getName();
            listModel_all.addElement(name);
        }
    }
}
 
源代码2 项目: netbeans   文件: NewPluginPanel.java
private void updateGoals() {
    DefaultListModel m = (DefaultListModel) goalsList.getModel();
    m.clear();

    if (selVi != null) {
        Set<String> goals = null;
        try {
            goals = PluginIndexManager.getPluginGoals(selVi.getGroupId(),
                    selVi.getArtifactId(), selVi.getVersion());
        } catch (Exception ex) {
            // TODO - put err msg in dialog?
            Exceptions.printStackTrace(ex);
        }
        if (goals != null) {
            for (String goal : goals) {
                m.addElement(new GoalEntry(goal));
            }
        }
    }
}
 
源代码3 项目: netbeans   文件: AntArtifactChooser.java
/**
 * Set up GUI fields according to the requested project.
 * @param project a subproject, or null
 */
private void populateAccessory( Project project ) {
    
    DefaultListModel model = (DefaultListModel)jListArtifacts.getModel();
    model.clear();
    jTextFieldName.setText(project == null ? "" : ProjectUtils.getInformation(project).getDisplayName()); //NOI18N
    
    if ( project != null ) {
        
        List<AntArtifact> artifacts = new ArrayList<AntArtifact>();
        for (int i=0; i<artifactTypes.length; i++) {
            artifacts.addAll (Arrays.asList(AntArtifactQuery.findArtifactsByType(project, artifactTypes[i])));
        }
        
        for(AntArtifact artifact : artifacts) {
            URI uris[] = artifact.getArtifactLocations();
            for( int y = 0; y < uris.length; y++ ) {
                model.addElement( new AntArtifactItem(artifact, uris[y]));
            }
        }
        jListArtifacts.setSelectionInterval(0, model.size());
    }
    
}
 
源代码4 项目: rapidminer-studio   文件: RadVizPlotter.java
@Override
public void setDataTable(DataTable dataTable) {
	super.setDataTable(dataTable);
	this.dataTable = dataTable;

	// ignore list
	DefaultListModel<String> ignoreModel = (DefaultListModel<String>) ignoreList.getModel();
	ignoreModel.clear();
	for (int i = 0; i < this.dataTable.getNumberOfColumns(); i++) {
		if (i == colorColumn) {
			continue;
		}
		ignoreModel.addElement(this.dataTable.getColumnName(i));
	}

	this.maxWeight = getMaxWeight(dataTable);

	repaint();
}
 
源代码5 项目: rapidminer-studio   文件: RadVizPlotter.java
@Override
public void setPlotColumn(int index, boolean plot) {
	if (plot) {
		this.colorColumn = index;
	} else {
		this.colorColumn = -1;
	}
	// ignore list
	DefaultListModel<String> ignoreModel = (DefaultListModel<String>) ignoreList.getModel();
	ignoreModel.clear();
	for (int i = 0; i < this.dataTable.getNumberOfColumns(); i++) {
		if (i == this.colorColumn) {
			continue;
		}
		ignoreModel.addElement(this.dataTable.getColumnName(i));
	}
	repaint();
}
 
源代码6 项目: cakephp3-netbeans   文件: GoToPopup.java
private void fireChange() {
    final DefaultListModel<GoToItem> model = (DefaultListModel<GoToItem>) jList1.getModel();
    model.clear();
    String filter = getFilter();
    for (GoToItem item : items) {
        FileObject fileObject = item.getFileObject();
        if (fileObject == null) {
            continue;
        }
        if (fileObject.getNameExt().toLowerCase().contains(filter.toLowerCase())) {
            model.addElement(item);
        }
    }
    if (!model.isEmpty()) {
        jList1.setSelectedIndex(0);
    }
    jList1.setSize(jList1.getPreferredSize());
    jList1.setVisibleRowCount(model.getSize());
    firePropertyChange(PopupUtil.COMPONENT_SIZE_CHANGED, null, null);
}
 
源代码7 项目: bboxdb   文件: BBoxDBGui.java
/**
 * Refresh the distributions groups
 * @param listModel
 */
private void refreshDistributionGroups(final DefaultListModel<String> listModel) {
	final List<String> distributionGroups = new ArrayList<>();

	try {
		distributionGroups.addAll(guiModel.getDistributionGroups());
	} catch (Exception e) {
		logger.error("Got an exception while loading distribution groups");
	}

	Collections.sort(distributionGroups);
	listModel.clear();
	
	for(final String distributionGroupName : distributionGroups) {
		listModel.addElement(distributionGroupName);
	}
	
	guiModel.setDistributionGroup(null);
	guiModel.unregisterTreeChangeListener();
	
	if(statusLabel != null) {
		statusLabel.setText("");
	}
}
 
源代码8 项目: PolyGlot   文件: ScrFamilies.java
/**
 * updates words list for family
 */
private void updateWordsProp() {
    FamTreeNode curNode = (FamTreeNode) treFam.getLastSelectedPathComponent();

    DefaultListModel<Object> model = (DefaultListModel<Object>) lstWords.getModel();

    model.clear();

    if (curNode == null) {
        return;
    }

    ConWord[] words;

    if (chkInclSubFam.isSelected()) {
        words = curNode.getNode().getWordsIncludeSubs();
    } else {
        words = curNode.getNode().getWords();
    }

    for (int i = 0; i < words.length; i++) {
        model.add(i, words[i]);
    }
}
 
源代码9 项目: MeteoInfo   文件: FrmJoinNCFiles.java
private void jButton_SelectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_SelectAllActionPerformed
    // TODO add your handling code here:
    DefaultListModel listModel_all = (DefaultListModel)this.jList_AllFiles.getModel();
    DefaultListModel listModel_sel = (DefaultListModel)this.jList_SelectedFiles.getModel();
    listModel_sel.clear();
    for (int i = 0; i < listModel_all.getSize(); i++){
        listModel_sel.addElement(listModel_all.getElementAt(i));
    }
}
 
源代码10 项目: netbeans   文件: CategoryPanelFormatters.java
@Override
public void load() {
    VariablesFormatter[] formatters = VariablesFormatter.loadFormatters();
    DefaultListModel filterClassesModel = (DefaultListModel) formattersList.getModel();
    filterClassesModel.clear();
    if (formatters != null) {
        for (int i = 0; i < formatters.length; i++) {
            filterClassesModel.addElement(formatters[i]);
        }
        if (formatters.length > 0) {
            formattersList.setSelectedValue(formatters[0], true);
        }
    }
}
 
源代码11 项目: netbeans   文件: FolderList.java
public void setFiles (File[] files) {
    DefaultListModel model = ((DefaultListModel)this.roots.getModel());
    model.clear();
    for (int i=0; i<files.length; i++) {
        model.addElement (files[i]);
    }
    if (files.length>0) {
        this.roots.setSelectedIndex(0);
    }
}
 
源代码12 项目: netbeans   文件: EarProjectPropertiesTest.java
public void testResolveProjectDependencies() throws Exception {
    
    int countBefore = EarProjectProperties.getJarContentAdditional(earProject).size();
    DefaultListModel l = earProjectProperties.EAR_CONTENT_ADDITIONAL_MODEL.getDefaultListModel();
    l.remove(l.indexOf(getEjbProject()));
    earProjectProperties.store();
    
    EditableProperties ep = TestUtil.loadProjectProperties(earProject.getProjectDirectory());
    String ejbReferenceValue = ep.getProperty(EJB_REFERENCE_EXPECTED_KEY);
    assertNull("ejb reference should not exist", ejbReferenceValue);
    String carReferenceValue = ep.getProperty(CAR_REFERENCE_EXPECTED_KEY);
    assertEquals("car reference should exist", CAR_REFERENCE_EXPECTED_VALUE, carReferenceValue);
    assertEquals("wrong count of project references", countBefore - 1, EarProjectProperties.getJarContentAdditional(earProject).size());
    assertEquals("wrong count of project references", countBefore - 1, earProject.getReferenceHelper().getRawReferences().length);
    
    // remove all entries
    l.clear();
    earProjectProperties.store();
    assertEquals("wrong count of project references", 0, EarProjectProperties.getJarContentAdditional(earProject).size());
    
    // add new project/module
    l.addElement(getWebProject());
    earProjectProperties.store();
    
    ep = TestUtil.loadProjectProperties(earProject.getProjectDirectory());
    ejbReferenceValue = ep.getProperty(EJB_REFERENCE_EXPECTED_KEY);
    assertNull("ejb reference should not exist", ejbReferenceValue);
    carReferenceValue = ep.getProperty(CAR_REFERENCE_EXPECTED_KEY);
    assertNull("car reference should not exist", carReferenceValue);
    String webReferenceValue = ep.getProperty(WEB_REFERENCE_EXPECTED_KEY);
    assertEquals("web reference should exist", WEB_REFERENCE_EXPECTED_VALUE, webReferenceValue);
    assertEquals("wrong count of project references", 1, EarProjectProperties.getJarContentAdditional(earProject).size());
    assertEquals("wrong count of project references", 1, earProject.getReferenceHelper().getRawReferences().length);
}
 
源代码13 项目: ramus   文件: JSModulesEditor.java
public void loadModules() {
    String[] streamNames = engine.getStreamNames();
    DefaultListModel model = (DefaultListModel) jList.getModel();
    model.clear();

    Arrays.sort(streamNames);

    for (String streamName : streamNames)
        if (streamName.startsWith(PREFIX))
            model.addElement(new Script(streamName));

}
 
private void loadTestDataLists() {
    DefaultListModel dfM = (DefaultListModel) testDataList.getModel();
    dfM.clear();
    List<String> values = tdProxy.getListOfTestDatas(environments.getSelectedItem().toString());
    values.stream().forEach((value) -> {
        dfM.addElement(value);
    });
}
 
源代码15 项目: deobfuscator-gui   文件: SwingConfiguration.java
/**
 * Clears the component value.
 */
public void clearValue()
{
	if(type == ItemType.FILE)
		((JTextField)component).setText("");
	else if(type == ItemType.BOOLEAN)
		((JCheckBox)component).setSelected(false);
	else
	{
		DefaultListModel<Object> listModel = (DefaultListModel<Object>)component;
		listModel.clear();
	}
}
 
源代码16 项目: wandora   文件: QueryLibraryPanel.java
public void readQueries(Options options){
    StoredQuery[] queries=null;
    String queriesJson=options.get(OPTIONS_KEY);
    if(queriesJson!=null){
        JsonMapper mapper=new JsonMapper();
        try{
            StoredQueries wrapper=(StoredQueries)mapper.readValue(queriesJson,StoredQueries.class);
            queries=wrapper.queries;
        }
        catch(IOException ioe){Wandora.getWandora().handleError(ioe);}
    }
    else queries=new StoredQuery[0];
    
    if(queries!=null){
        synchronized(storedQueries){
            storedQueries.clear();
            storedQueries.addAll(Arrays.asList(queries));

            DefaultListModel model=(DefaultListModel)queryList.getModel();            
            model.clear();
            for(StoredQuery q : storedQueries){
                model.addElement(q);
            }
            
        }
    }

}
 
源代码17 项目: diirt   文件: CompareResultImages.java
private void fillList() {
        DefaultListModel newModel = (DefaultListModel) toReviewList.getModel();
        newModel.clear();
        for (TestResultManager.Result result : manager.getCurrentResults()) {
            newModel.addElement(result);
        }
//        toReviewList.setModel(newModel);
    }
 
源代码18 项目: MeteoInfo   文件: FrmJoinNCFiles.java
private void jButton_UnSelectAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_UnSelectAllActionPerformed
    // TODO add your handling code here:
    DefaultListModel listModel_sel = (DefaultListModel)this.jList_SelectedFiles.getModel();
    listModel_sel.clear();
}
 
源代码19 项目: freecol   文件: BuildQueuePanel.java
/**
 * Update the list of available buildings to build
 *
 * This method will verify whether a building can be built by
 *      checking against the following criteria:
 *       * Does the Colony meet the population limit to build?
 *       * Does the new building require a special circumstance,
 *              such as a prerequisite unit or building?
 */
private void updateBuildingList() {
    final Specification spec = getSpecification();
    final DefaultListModel<BuildableType> current
        = (DefaultListModel<BuildableType>)this.buildQueueList.getModel();
    final DefaultListModel<BuildingType> buildings
        = (DefaultListModel<BuildingType>)this.buildingList.getModel();
    buildings.clear();
    Set<BuildableType> unbuildableTypes = new HashSet<>();

    // For each building type, find out if it is buildable, and
    // reasons to not build it (and perhaps display a lock icon).
    for (BuildingType bt : spec.getBuildingTypeList()) {
        if (unbuildableTypes.contains(bt)) continue;

        // Impossible upgrade path
        if (bt.getUpgradesFrom() != null
            && unbuildableTypes.contains(bt.getUpgradesFrom())) {
            unbuildableTypes.add(bt);
            continue;
        }

        // Ignore pre-built buildings
        if (!bt.needsGoodsToBuild()) continue;
        
        // Only one building of any kind
        if (current.contains(bt) || hasBuildingType(bt)) continue;
        
        List<String> reasons = new ArrayList<>(8);

        // Coastal limit
        if (bt.hasAbility(Ability.COASTAL_ONLY)
            && !this.colony.getTile().isCoastland()) {
            reasons.add(Messages.message(StringTemplate
                    .template("buildQueuePanel.coastalOnly")));
        }

        // Population limit
        if (bt.getRequiredPopulation() > this.colony.getUnitCount()) {
            reasons.add(Messages.message(StringTemplate
                    .template("buildQueuePanel.populationTooSmall")
                    .addAmount("%number%", bt.getRequiredPopulation())));
        }

        // Spec limits
        for (Limit limit : transform(bt.getLimits(),
                                     l -> !l.evaluate(this.colony))) {
            reasons.add(Messages.getDescription(limit));
        }

        // Missing ability
        if (!checkAbilities(bt, reasons)) unbuildableTypes.add(bt);

        // Upgrade path is blocked
        Building colonyBuilding = this.colony.getBuilding(bt);
        BuildingType up = bt.getUpgradesFrom();
        if (up != null && !current.contains(up)
            && (colonyBuilding == null || colonyBuilding.getType() != up)) {
            reasons.add(Messages.getName(up));
        }

        lockReasons.put(bt, (reasons.isEmpty()) ? null
            : Messages.message(StringTemplate
                .template("buildQueuePanel.requires")
                .addName("%string%", join("/", reasons))));
        if (reasons.isEmpty()
            || showAllBox.isSelected()) buildings.addElement(bt);
    }
}
 
源代码20 项目: freecol   文件: BuildQueuePanel.java
/**
 * Update the list of available units (ships, wagon, artillery) to build
 *
 * This method will verify whether a unit can be built by
 *      checking against the following criteria:
 *       * Does the Colony meet the population limit to build?
 *       * Does the new building require a special circumstance,
 *              such as a prerequisite unit or building?
 */
private void updateUnitList() {
    final Specification spec = getSpecification();
    final Turn turn = getGame().getTurn();
    DefaultListModel<UnitType> units
        = (DefaultListModel<UnitType>)this.unitList.getModel();
    units.clear();
    Set<BuildableType> unbuildableTypes = new HashSet<>();
    
    // For each unit type, find out if it is buildable, and
    // reasons to not build it (and perhaps display a lock icon).
    for (UnitType ut : spec.getBuildableUnitTypes()) {
        if (unbuildableTypes.contains(ut)) continue;

        List<String> reasons = new ArrayList<>(8);

        // Population limit
        if (ut.getRequiredPopulation() > this.colony.getUnitCount()) {
            reasons.add(Messages.message(StringTemplate
                    .template("buildQueuePanel.populationTooSmall")
                    .addAmount("%number%", ut.getRequiredPopulation())));
        }

        // Spec limits
        for (Limit limit : transform(ut.getLimits(),
                                     l -> !l.evaluate(this.colony))) {
            reasons.add(Messages.getDescription(limit));
        }

        // Missing ability
        if (!checkAbilities(ut, reasons)) unbuildableTypes.add(ut);

        // Missing unit build ability?
        if (!this.featureContainer.hasAbility(Ability.BUILD, ut, null)
            && !this.colony.hasAbility(Ability.BUILD, ut, turn)) {
            Ability buildAbility = find(spec.getAbilities(Ability.BUILD),
                a -> (a.appliesTo(ut)
                    && a.getValue()
                    && a.getSource() != null
                    && !unbuildableTypes.contains(a.getSource())));
            reasons.add((buildAbility != null)
                ? ((buildAbility.getSource() instanceof Named)
                    ? Messages.getName((Named)buildAbility.getSource())
                    : Messages.getName(buildAbility))
                : Messages.getName(ut));
        }

        lockReasons.put(ut, (reasons.isEmpty()) ? null
            : Messages.message(StringTemplate
                .template("buildQueuePanel.requires")
                .addName("%string%", join("/", reasons))));
        if (reasons.isEmpty()
            || showAllBox.isSelected()) units.addElement(ut);
    }
}