Java 类org.openide.util.NbCollections 实例源码

项目:incubator-netbeans    文件:SetupUtil.java   
public MainFS() {
    ALL.addLookupListener(this);

    List<URL> layerUrls = new ArrayList<URL>();
    ClassLoader l = Thread.currentThread().getContextClassLoader();
    try {
        for (URL manifest : NbCollections.iterable(l.getResources("META-INF/MANIFEST.MF"))) { // NOI18N
            InputStream is = manifest.openStream();
            try {
                Manifest mani = new Manifest(is);
                String layerLoc = mani.getMainAttributes().getValue("OpenIDE-Module-Layer"); // NOI18N
                if (layerLoc != null) {
                    URL layer = l.getResource(layerLoc);
                    if (layer != null) {
                        layerUrls.add(layer);
                    }
                }
            } finally {
                is.close();
            }
        }
        layers.setXmlUrls(layerUrls.toArray(new URL[layerUrls.size()]));
    } catch (Exception x) {
    }
    resultChanged(null); // run after add listener - see PN1 in #26338
}
项目:incubator-netbeans    文件:BridgeImpl.java   
public @Override void run() {
    IntrospectedInfo custom = AntSettings.getCustomDefs();
    @SuppressWarnings("rawtypes")
    Map<String,Map<String,Class>> defs = new HashMap<String, Map<String, Class>>();
    try {
        defs.put("task", NbCollections.checkedMapByCopy(project.getTaskDefinitions(), String.class, Class.class, true));
        defs.put("type", NbCollections.checkedMapByCopy(project.getDataTypeDefinitions(), String.class, Class.class, true));
    } catch (ThreadDeath t) {
        // #137883: late clicks on Stop which can be ignored.
    }
    custom.scanProject(defs);
    AntSettings.setCustomDefs(custom);
    logger.shutdown();
    // #85698: do not invoke multiple refreshes at once
    refreshFilesystemsTask.schedule(0);
    gutProject(project);
    // #185853: make sure these fields do not stick around
    project = null;
    logger = null;
}
项目:incubator-netbeans    文件:ShortcutWizard.java   
private static void doRemove(FileObject shortcut) throws IOException {
    for (String place : new String[] {"Menu", "Toolbars", "Shortcuts", "Keymaps"}) { // NOI18N
        FileObject top = FileUtil.getConfigFile(place);
        if (top != null) {
            for (FileObject f : NbCollections.iterable(top.getChildren(true))) {
                DataObject d;
                try {
                    d = DataObject.find(f);
                } catch (DataObjectNotFoundException x) {
                    LOG.log(Level.INFO, "Loading " + f, x);
                    continue;
                }
                if (d instanceof DataShadow && ((DataShadow) d).getOriginal().getPrimaryFile() == shortcut) {
                    delete(f);
                }
            }
        }
    }
    delete(shortcut);
}
项目:incubator-netbeans    文件:AdvancedActionPanel.java   
private void targetComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_targetComboBoxActionPerformed
    String selection = (String) targetComboBox.getSelectedItem();
    if (selection == null) {
        // Why? Not sure. #45097.
        selection = "";
    }
    StringTokenizer tok = new StringTokenizer(selection, " ,"); // NOI18N
    List<String> targetsL = Collections.list(NbCollections.checkedEnumerationByFilter(tok, String.class, true));
    String description = "";
    if (targetsL.size() == 1) {
        String targetName = targetsL.get(0);
        for (TargetLister.Target target : allTargets) {
            if (!target.isOverridden() && target.getName().equals(targetName)) {
                description = target.getElement().getAttribute("description"); // NOI18N
                // may still be "" if not defined
                break;
            }
        }
    }
    targetDescriptionField.setText(description);
}
项目:incubator-netbeans    文件:ModuleList.java   
private static PropertyEvaluator parseSuiteProperties(File root) throws IOException {
    Properties p = System.getProperties();
    Map<String,String> predefs;
    synchronized (p) {
        predefs = NbCollections.checkedMapByCopy(p, String.class, String.class, false);
    }
    predefs.put("basedir", root.getAbsolutePath()); // NOI18N
    PropertyProvider predefsProvider = PropertyUtils.fixedPropertyProvider(predefs);
    List<PropertyProvider> providers = new ArrayList<PropertyProvider>();
    providers.add(loadPropertiesFile(new File(root, "nbproject" + File.separatorChar + "private" + File.separatorChar + "platform-private.properties"))); // NOI18N
    providers.add(loadPropertiesFile(new File(root, "nbproject" + File.separatorChar + "platform.properties"))); // NOI18N
    PropertyEvaluator eval = PropertyUtils.sequentialPropertyEvaluator(predefsProvider, providers.toArray(new PropertyProvider[providers.size()]));
    String buildS = eval.getProperty("user.properties.file"); // NOI18N
    if (buildS != null) {
        providers.add(loadPropertiesFile(PropertyUtils.resolveFile(root, buildS)));
    } else {
        // Never been opened, perhaps - so fake it.
        providers.add(PropertyUtils.globalPropertyProvider());
    }
    providers.add(loadPropertiesFile(new File(root, "nbproject" + File.separatorChar + "private" + File.separatorChar + "private.properties"))); // NOI18N
    providers.add(loadPropertiesFile(new File(root, "nbproject" + File.separatorChar + "project.properties"))); // NOI18N
    eval = PropertyUtils.sequentialPropertyEvaluator(predefsProvider, providers.toArray(new PropertyProvider[providers.size()]));
    providers.add(new DestDirProvider(eval));
    return PropertyUtils.sequentialPropertyEvaluator(predefsProvider, providers.toArray(new PropertyProvider[providers.size()]));
}
项目:incubator-netbeans    文件:ApisupportAntUtils.java   
private static Iterable<String> getPossibleResources(String locBundleResource) {
    String locBundleResourceBase, locBundleResourceExt;
    int idx = locBundleResource.lastIndexOf('.');
    if (idx != -1 && idx > locBundleResource.lastIndexOf('/')) {
        locBundleResourceBase = locBundleResource.substring(0, idx);
        locBundleResourceExt = locBundleResource.substring(idx);
    } else {
        locBundleResourceBase = locBundleResource;
        locBundleResourceExt = "";
    }
    Collection<String> resources = new LinkedHashSet<String>();
    for (String suffix : NbCollections.iterable(NbBundle.getLocalizingSuffixes())) {
        String resource = locBundleResourceBase + suffix + locBundleResourceExt;
        resources.add(resource);
        resources.add(resource);
}
    return resources;
}
项目:incubator-netbeans    文件:SuitePropertiesTest.java   
public void testAddModule() throws Exception {
    SuiteProject suite1 = generateSuite("suite1");
    TestBase.generateSuiteComponent(suite1, "module1");

    SubprojectProvider spp = getSubProjectProvider(suite1);
    SuiteProperties suiteProps = getSuiteProperties(suite1);

    SuiteSubModulesListModel model = suiteProps.getModulesListModel();
    assertEquals("one module suite component", 1, model.getSize());

    NbModuleProject module2ToAdd = generateStandaloneModule("module2");
    NbModuleProject module3ToAdd = generateStandaloneModule("module3");
    assertNull(module2ToAdd.getLookup().lookup(SuiteProvider.class));
    model.addModule(module2ToAdd);
    model.addModule(module3ToAdd);

    saveProperties(suiteProps);

    SuiteProvider suiteProvider = module2ToAdd.getLookup().lookup(SuiteProvider.class);
    assertNotNull(suiteProvider);
    assertNotNull(suiteProvider.getSuiteDirectory());

    suiteProps.refresh(NbCollections.checkedSetByFilter(spp.getSubprojects(), NbModuleProject.class, true));
    assertNotNull(suiteProvider.getSuiteDirectory());
    assertEquals("three module suite components", 3, suiteProps.getModulesListModel().getSize());
}
项目:incubator-netbeans    文件:SuitePropertiesTest.java   
public void testRemovingSecondModuleFromThree_63307() throws Exception {
    SuiteProject suite1 = generateSuite("suite1");
    TestBase.generateSuiteComponent(suite1, "module1");
    NbModuleProject module2 = TestBase.generateSuiteComponent(suite1, "module2");
    TestBase.generateSuiteComponent(suite1, "module3");

    SubprojectProvider spp = getSubProjectProvider(suite1);
    SuiteProperties suiteProps = getSuiteProperties(suite1);

    SuiteSubModulesListModel model = suiteProps.getModulesListModel();
    assertEquals("three module suite components", 3, model.getSize());
    model.removeModules(Arrays.asList(new Object[] { module2 }));

    saveProperties(suiteProps);

    suiteProps.refresh(NbCollections.checkedSetByFilter(spp.getSubprojects(), NbModuleProject.class, true));
    assertEquals("two module suite components", 2, suiteProps.getModulesListModel().getSize());
}
项目:incubator-netbeans    文件:ModuleListTest.java   
public void testConcurrentModificationOfSystemProperties3() throws InterruptedException {
    Thread t = new Thread(new Runnable() {

        public void run() {
            for (int i = 0; i < 20000; i++) {
                System.setProperty("whatever", "anything" + i);
            }
        }
    });
    t.start();
    Properties p = System.getProperties();
    for (int i = 0; i < 2000; i++) {
        synchronized (p) {
            Map<String, String> props = NbCollections.checkedMapByCopy(p, String.class, String.class, false);
        }
    }
    t.join();
}
项目:incubator-netbeans    文件:BrandingSupport.java   
private void loadLocalizedBundlesFromPlatform(final BrandableModule moduleEntry,
        final String bundleEntry, final Set<String> keys, final Set<BundleKey> bundleKeys) throws IOException {
    Properties p = new Properties();
    JarFile module = new JarFile(moduleEntry.getJarLocation());
    JarEntry je = module.getJarEntry(bundleEntry);
    InputStream is = module.getInputStream(je);
    File bundle = new File(getModuleEntryDirectory(moduleEntry),bundleEntry);
    try {

        p.load(is);
    } finally {
        is.close();
    }
    for (String key : NbCollections.checkedMapByFilter(p, String.class, String.class, true).keySet()) {
        if (keys.contains(key)) {
            String value = p.getProperty(key);
            bundleKeys.add(new BundleKey(moduleEntry, bundle, key, value));
        } 
    }
}
项目:incubator-netbeans    文件:NetigsoLoader.java   
@Override
public Enumeration<URL> findResources(String name) {
    //Netigso.start();
    Bundle b = bundle;
    if (b == null) {
        LOG.log(Level.WARNING, "Trying to load resource before initialization finished {0}", name);
        return Enumerations.empty();
    }
    Enumeration ret = null;
    try {
        if (b.getState() != Bundle.UNINSTALLED) {
            ret = b.getResources(name);
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
    return ret == null ? Enumerations.<URL>empty() : NbCollections.checkedEnumerationByFilter(ret, URL.class, true);
}
项目:incubator-netbeans    文件:ProjectTemplateAttributesProvider.java   
static Map<String, ? extends Object> checkProjectAttrs(Map<String, Object>  check, Map<String, Object> m, FileObject parent) {
    Object prjAttrObj = check != null ? check.get(ATTR_PROJECT) : null;
    if (prjAttrObj instanceof Map) {
        Map<String, Object> prjAttrs = NbCollections.checkedMapByFilter((Map) prjAttrObj, String.class, Object.class, false);
        Map<String, Object> newPrjAttrs = new HashMap<String, Object>(prjAttrs);
        m.put(ATTR_PROJECT, newPrjAttrs);
        ensureProjectAttrs(newPrjAttrs, parent);
        return m;
    }
    if (prjAttrObj != null) {
        // What can we do?
        return m;
    }
    Map<String, Object> projectMap = new HashMap<String, Object>();
    ensureProjectAttrs(projectMap, parent);
    if (m != null) {
        m.put(ATTR_PROJECT, projectMap); // NOI18N
        return m;
    }
    return Collections.singletonMap(ATTR_PROJECT, projectMap);
}
项目:incubator-netbeans    文件:DataObjectRegistrationHinter.java   
@Messages({
    "# {0} - file attribute name", "DataObjectHinter_unrecognized_attr=Unrecognized DataObject attribute: {0}",
    "DataObjectRegistrationHinter.use.displayName=Please convert to displayName to be able to use Loader hinter"
})
private boolean checkAttributes(FileObject file, Context ctx) {
    boolean attributesCompatible = true;
    for (String attr : NbCollections.iterable(file.getAttributes())) {
        if (!attr.matches("mimeType|position|displayName|iconBase|dataObjectClass|instanceCreate|SystemFileSystem.localizingBundle")) {
            ctx.addHint(Severity.WARNING, DataObjectHinter_unrecognized_attr(attr));
            attributesCompatible = false;
        }
    }
    if (file.getAttribute("literal:SystemFileSystem.localizingBundle") != null) {
        attributesCompatible = false;
        ctx.addHint(Severity.HINT, DataObjectRegistrationHinter_use_displayName());
    }
    return attributesCompatible;
}
项目:incubator-netbeans    文件:HudsonRemoteFileSystem.java   
/**
 * For {@link HudsonInstanceImpl} to refresh after the workspace has been synchronized.
 */
@Override
public void refreshAll() {
    LOG.log(Level.FINE, "refreshing files in {0}", baseURL);
    synchronized (nonDirs) {
        nonDirs.clear();
        lastModified.clear();
        size.clear();
        headers.clear();
    }
    for (FileObject f : NbCollections.iterable(existingFileObjects(getRoot()))) {
        if (Thread.interrupted()) {
            return;
        }
        LOG.log(Level.FINER, "  refreshing {0}", f.getPath());
        f.refresh();
    }
}
项目:incubator-netbeans    文件:ProjectTab.java   
public @Override void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    super.readExternal( in );
    id = (String)in.readObject();
    rootNode = ((Node.Handle)in.readObject()).getNode();
    final List<String[]> exPaths = NbCollections.checkedListByCopy((List<?>) in.readObject(), String[].class, true);
    final List<String[]> selPaths = new ArrayList<String[]>();
    try {
        selPaths.addAll(NbCollections.checkedListByCopy((List<?>) in.readObject(), String[].class, true));
    }
    catch ( java.io.OptionalDataException e ) {
        // Sel paths missing
    }
    initValues();
    if (!"false".equals(System.getProperty("netbeans.keep.expansion"))) { // #55701
        KeepExpansion ke = new KeepExpansion(exPaths, selPaths);
        ke.task.schedule(0);
    }
}
项目:incubator-netbeans    文件:ProjectLibraryProvider.java   
private static Map<String,String> loadProperties(File f) {
    if (!f.isFile()) {
        return Collections.emptyMap();
    }
    Properties p = new Properties();
    try {
        InputStream is = new FileInputStream(f);
        try {
            p.load(is);
        } finally {
            is.close();
        }
        return NbCollections.checkedMapByFilter(p, String.class, String.class, true);
    } catch (IOException x) {
        LOG.log(Level.INFO, "Loading: " + f, x);
        return Collections.emptyMap();
    }
}
项目:incubator-netbeans    文件:ProjectProperties.java   
/**
 * See {@link AntProjectHelper#getStockPropertyPreprovider}.
 */
@SuppressWarnings("SleepWhileInLoop")
public PropertyProvider getStockPropertyPreprovider() {
    if (stockPropertyPreprovider == null) {
        Map<String,String> m = null;
        while (m == null) {
            try {
                m = NbCollections.checkedMapByCopy(System.getProperties(), String.class, String.class, false);
            } catch (ConcurrentModificationException x) { // #194904, but do not synchronize (#212007)
                try {
                    Thread.sleep(100);
                } catch (InterruptedException x2) {}
            }
        }
        m.put("basedir", FileUtil.toFile(helper.getProjectDirectory()).getAbsolutePath()); // NOI18N
        File _antJar = antJar();
        if (_antJar != null) {
            File antHome = _antJar.getParentFile().getParentFile();
            m.put("ant.home", antHome.getAbsolutePath()); // NOI18N
            m.put("ant.core.lib", _antJar.getAbsolutePath()); // NOI18N
        }
        stockPropertyPreprovider = PropertyUtils.fixedPropertyProvider(m);
    }
    return stockPropertyPreprovider;
}
项目:incubator-netbeans    文件:PropertyUtils.java   
private Map<String,String> loadProperties() {
    // XXX does this need to run in PM.mutex.readAccess?
    if (properties.isFile() && properties.canRead()) {
        try {
            InputStream is = new FileInputStream(properties);
            try {
                Properties props = new Properties();
                props.load(is);
                return NbCollections.checkedMapByFilter(props, String.class, String.class, true);
            } catch (IllegalArgumentException iae) {
                Logger.getLogger(PropertyUtils.class.getName()).log(Level.WARNING, "Property file: " + properties.getPath(), iae);
            } finally {
                is.close();
            }
        } catch (IOException e) {
            Logger.getLogger(PropertyUtils.class.getName()).log(Level.INFO, null, e);
        }
    }
    // Missing or erroneous.
    return Collections.emptyMap();
}
项目:incubator-netbeans    文件:BIEditorSupport.java   
private void updateMVTCNameInAwt() {
    CloneableTopComponent topComp = multiviewTC;
    if (topComp != null) {
        String htmlname = messageHtmlName();
        String name = messageName();
        String tip = messageToolTip();
        for (CloneableTopComponent o : NbCollections.
                iterable(topComp.getReference().getComponents())) {

            topComp.setHtmlDisplayName(htmlname);
            topComp.setDisplayName(name);
            topComp.setName(name);
            topComp.setToolTipText(tip);
        }
    }
}
项目:incubator-netbeans    文件:SetupUtil.java   
public MainFS() {
    ALL.addLookupListener(this);

    List<URL> layerUrls = new ArrayList<URL>();
    ClassLoader l = Thread.currentThread().getContextClassLoader();
    try {
        for (URL manifest : NbCollections.iterable(l.getResources("META-INF/MANIFEST.MF"))) { // NOI18N
            InputStream is = manifest.openStream();
            try {
                Manifest mani = new Manifest(is);
                String layerLoc = mani.getMainAttributes().getValue("OpenIDE-Module-Layer"); // NOI18N
                if (layerLoc != null) {
                    URL layer = l.getResource(layerLoc);
                    if (layer != null) {
                        layerUrls.add(layer);
                    }
                }
            } finally {
                is.close();
            }
        }
        layers.setXmlUrls(layerUrls.toArray(new URL[layerUrls.size()]));
    } catch (Exception x) {
    }
    resultChanged(null); // run after add listener - see PN1 in #26338
}
项目:incubator-netbeans    文件:AbstractFileSystemCompat.java   
@Deprecated
public FileObject find(String aPackage, String name, String ext) {
    // create enumeration of name to look for
    Enumeration<String> st = NbCollections.checkedEnumerationByFilter(new StringTokenizer(aPackage, "."), String.class, true); // NOI18N

    if ((name == null) || (ext == null)) {
        // search for folder, return the object only if it is folder
        FileObject fo = afs().getAbstractRoot().find(st);

        return ((fo != null) && fo.isFolder()) ? fo : null;
    } else {
        Enumeration<String> en = Enumerations.concat(st, Enumerations.singleton(name + '.' + ext));

        // tries to find it (can return null)
        return afs().getAbstractRoot().find(en);
    }
}
项目:incubator-netbeans    文件:NbCollectionsTest.java   
public void testCheckedSetByCopy() throws Exception {
    Set s = new HashSet();
    s.add(1);
    s.add(2);
    Set<Integer> checked = NbCollections.checkedSetByCopy(s, Integer.class, true);
    assertEquals(s, checked);
    s.add("three");
    try {
        NbCollections.checkedSetByCopy(s, Integer.class, true);
        fail();
    } catch (ClassCastException e) {/*OK*/}
    assertEquals(checked, NbCollections.checkedSetByCopy(s, Integer.class, false));
    s.remove("three");
    s.add(null);
    checked = NbCollections.checkedSetByCopy(s, Integer.class, true);
    assertEquals("nulls preserved", s, checked);
    s.clear();
    s.add(5);
    assertEquals("modifications to original not reflected", 3, checked.size());
}
项目:incubator-netbeans    文件:NbCollectionsTest.java   
private void doTestCheckedListByCopy(List l) {
    l.add(1);
    l.add(2);
    List<Integer> checked = NbCollections.checkedListByCopy(l, Integer.class, true);
    assertEquals(l, checked);
    l.add("three");
    try {
        NbCollections.checkedListByCopy(l, Integer.class, true);
        fail();
    } catch (ClassCastException e) {/*OK*/}
    assertEquals(checked, NbCollections.checkedListByCopy(l, Integer.class, false));
    l.remove("three");
    l.add(null);
    checked = NbCollections.checkedListByCopy(l, Integer.class, true);
    assertEquals("nulls preserved", l, checked);
    l.clear();
    l.add(5);
    assertEquals("modifications to original not reflected", 3, checked.size());
}
项目:incubator-netbeans    文件:MakeSharableVisualPanel2.java   
void readSettings(WizardDescriptor wiz) {
    String loc = (String) wiz.getProperty(SharableLibrariesUtils.PROP_LOCATION);
    helper = (AntProjectHelper) wiz.getProperty(SharableLibrariesUtils.PROP_HELPER);
    refhelper = (ReferenceHelper) wiz.getProperty(SharableLibrariesUtils.PROP_REFERENCE_HELPER);
    List<String> libraries = NbCollections.checkedListByCopy((List) wiz.getProperty(SharableLibrariesUtils.PROP_LIBRARIES), String.class, true);
    List<String> jars = NbCollections.checkedListByCopy((List) wiz.getProperty(SharableLibrariesUtils.PROP_JAR_REFS), String.class, true);
    if (!loc.equals(location)) {
        location = loc;
        populateTable(helper, libraries, jars);
        populateDescriptionField();
    }
}
项目:incubator-netbeans    文件:VolumeContentModel.java   
private void propagateContent() {
    if (supportsURIContent) {
        LibrariesSupport.setURIContent(
            impl,
            volumeType,
            NbCollections.checkedListByCopy(content, URI.class, true),
            LibrariesSupport.ConversionMode.FAIL);
    } else {
        impl.setContent (volumeType, NbCollections.checkedListByCopy(content, URL.class, true));
    }
}
项目:incubator-netbeans    文件:NbBuildLogger.java   
public @Override Set<String> getPropertyNames() {
    verifyRunning();
    Project project = getProjectIfPropertiesDefined();
    if (project != null) {
        Set<String> s = new HashSet<String>();
        s.addAll(NbCollections.checkedSetByFilter(project.getProperties().keySet(), String.class, true));
        s.addAll(NbCollections.checkedSetByFilter(project.getReferences().keySet(), String.class, true));
        return s;
    } else {
        return Collections.emptySet();
    }
}
项目:incubator-netbeans    文件:NbBuildLogger.java   
public @Override TaskStructure[] getChildren() {
    verifyRunning();
    List<TaskStructure> structures = new ArrayList<TaskStructure>();
    for (RuntimeConfigurable subrc : NbCollections.iterable(getChildrenOfRuntimeConfigurable(rc))) {
        structures.add(LoggerTrampoline.TASK_STRUCTURE_CREATOR.makeTaskStructure(new TaskStructureImpl(subrc)));
    }
    return structures.toArray(new TaskStructure[structures.size()]);
}
项目:incubator-netbeans    文件:TargetLister.java   
/**
 * Gets all targets in an Ant script.
 * Some may come from imported scripts.
 * There is no guarantee that the actual {@link Target} objects will be
 * the same from call to call.
 * @param script an Ant build script
 * @return an immutable, unchanging set of {@link Target}s; may be empty
 * @throws IOException in case there is a problem reading the script (or a subscript)
 */
public static Set<Target> getTargets(AntProjectCookie script) throws IOException {
    Set<File> alreadyImported = new HashSet<File>();
    Map<String,String> properties = NbCollections.checkedMapByCopy(System.getProperties(), String.class, String.class, false);
    properties.putAll(AntSettings.getProperties()); // #130460
    Script main = new Script(null, script, alreadyImported, properties, Collections.<String,Element>emptyMap());
    Set<Target> targets = new HashSet<Target>();
    Set<AntProjectCookie> visitedScripts = new HashSet<AntProjectCookie>();
    traverseScripts(main, targets, visitedScripts);
    return targets;
}
项目:incubator-netbeans    文件:CustomizerLibraries.java   
private void removeModuleDependency(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeModuleDependency
    List<ModuleDependency> deps = NbCollections.checkedListByCopy(Arrays.asList(dependencyList.getSelectedValues()), ModuleDependency.class, false);
    if (deps.size() > 0) {
        getDepListModel().removeDependencies(deps);
        if (dependencyList.getModel().getSize() > 0) {
            dependencyList.setSelectedIndex(0);
        }
    }
    dependencyList.requestFocusInWindow();
}
项目:incubator-netbeans    文件:ModuleList.java   
private static PropertyProvider loadPropertiesFile(File f) throws IOException {
    if (!f.isFile()) {
        return PropertyUtils.fixedPropertyProvider(Collections.<String,String>emptyMap());
    }
    Properties p = new Properties();
    InputStream is = new FileInputStream(f);
    try {
        p.load(is);
    } finally {
        is.close();
    }
    return PropertyUtils.fixedPropertyProvider(NbCollections.checkedMapByFilter(p, String.class, String.class, true));
}
项目:incubator-netbeans    文件:SuitePropertiesTest.java   
public static SuiteProperties getSuiteProperties(SuiteProject suite) throws IOException {
    SubprojectProvider spp = getSubProjectProvider(suite);
    Set<NbModuleProject> subModules = NbCollections.checkedSetByCopy(spp.getSubprojects(), NbModuleProject.class, true);
    SuiteProperties suiteProps = new SuiteProperties(suite, suite.getHelper(),
            suite.getEvaluator(), subModules);
    return suiteProps;
}
项目:incubator-netbeans    文件:SuitePropertiesTest.java   
public void testRefreshing_63307() throws Exception {
    SuiteProject suite1 = generateSuite("suite1");
    TestBase.generateSuiteComponent(suite1, "module1");
    SubprojectProvider spp = getSubProjectProvider(suite1);
    SuiteProperties suiteProps = getSuiteProperties(suite1);
    assertEquals("one module", "${project.org.example.module1}", suiteProps.getProperty(SuiteUtils.MODULES_PROPERTY));
    TestBase.generateSuiteComponent(suite1, "module2");
    suiteProps.refresh(NbCollections.checkedSetByFilter(spp.getSubprojects(), NbModuleProject.class, true));
    assertEquals("two modules", "${project.org.example.module1}:${project.org.example.module2}", suiteProps.getProperty(SuiteUtils.MODULES_PROPERTY));
    assertEquals("two module suite component", 2, suiteProps.getModulesListModel().getSize());
}
项目:incubator-netbeans    文件:SuitePropertiesTest.java   
public void testRefreshingWithRemovedPlatformDoesNotThrowNPE() throws Exception {
    SuiteProject suite1 = TestBase.generateSuite(getWorkDir(), "suite1", "custom");
    SubprojectProvider spp = getSubProjectProvider(suite1);
    SuiteProperties suiteProps = getSuiteProperties(suite1);
    NbPlatform.removePlatform(NbPlatform.getPlatformByID("custom"));
    suiteProps.refresh(NbCollections.checkedSetByFilter(spp.getSubprojects(), NbModuleProject.class, true));
    assertNotNull(suiteProps.getActivePlatform());
    assertEquals("default platform", suiteProps.getActivePlatform(), NbPlatform.getDefaultPlatform());
}
项目:incubator-netbeans    文件:SuitePropertiesTest.java   
public void testCustomPropertiesReferences_61318() throws Exception {
    final SuiteProject suite1 = generateSuite("suite1");
    TestBase.generateSuiteComponent(suite1, "module1");
    NbModuleProject module2 = TestBase.generateSuiteComponent(suite1, "module2");
    TestBase.generateSuiteComponent(suite1, "module3");

    SubprojectProvider spp = getSubProjectProvider(suite1);
    final SuiteProperties suiteProps = getSuiteProperties(suite1);

    SuiteSubModulesListModel model = suiteProps.getModulesListModel();
    assertEquals("three module suite components", 3, model.getSize());

    ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
        public Void run() throws Exception {
            // choose another way to store submodules
            EditableProperties edProps = suiteProps.getProjectProperties();
            edProps.setProperty("moddir", ".");
            edProps.setProperty("modules", "${moddir}/module1:${moddir}/module2:${moddir}/module3");
            Util.storeProperties(
                    suite1.getProjectDirectory().getFileObject(AntProjectHelper.PROJECT_PROPERTIES_PATH),
                    edProps);
            return null;
        }
    });

    suiteProps.refresh(NbCollections.checkedSetByFilter(spp.getSubprojects(), NbModuleProject.class, true));
    model = suiteProps.getModulesListModel(); // reload
    assertEquals("three module suite components", 3, model.getSize());
    model.removeModules(Arrays.asList(new Object[] { module2 }));
    saveProperties(suiteProps);

    suiteProps.refresh(NbCollections.checkedSetByFilter(spp.getSubprojects(), NbModuleProject.class, true));
    model = suiteProps.getModulesListModel(); // reload
    assertEquals("two module suite components", 2, model.getSize());
}
项目:incubator-netbeans    文件:ModuleListTest.java   
public void testConcurrentModificationOfSystemProperties2() throws InterruptedException {
    Thread t = new Thread(new Runnable() {

        public void run() {
            for (int i = 0; i < 20000; i++) {
                System.setProperty("whatever", "anything" + i);
            }
        }
    });
    t.start();
    for (int i = 0; i < 2000; i++) {
        Map<String, String> props = NbCollections.checkedMapByCopy((Map) System.getProperties().clone(), String.class, String.class, false);
    }
    t.join();
}
项目:incubator-netbeans    文件:AnnotationViewDataImpl.java   
private Mark getMainMarkForBlockAnnotations(int startLine, int endLine) {
    AnnotationDesc foundDesc = null;

    for (AnnotationDesc desc : NbCollections.iterable(listAnnotations(startLine, endLine))) {
        if ((foundDesc == null || isMoreImportant(desc, foundDesc)) && isValidForErrorStripe(desc))
            foundDesc = desc;
    }

    if (foundDesc != null)
        return new AnnotationMark(foundDesc);
    else
        return null;
}
项目:incubator-netbeans    文件:BadgingSupport.java   
private static ClassPath classpathForFile(FileObject fo) {
    URL[] layers = (URL[]) fo.getAttribute("layers"); // NOI18N
    if (layers != null) {
        for (URL layer : layers) {
            URL jar = FileUtil.getArchiveFile(layer);
            if (jar != null) {
                List<URL> roots = new ArrayList<URL>();
                roots.add(FileUtil.getArchiveRoot(jar));
                Matcher m = Pattern.compile("(file:.+/)([^/]+)[.]jar").matcher(jar.toString()); // NOI18N
                if (m.matches()) {
                    try {
                        for (String suffix : NbCollections.iterable(NbBundle.getLocalizingSuffixes())) {
                            roots.add(new URL("jar:" + m.group(1) + "locale/" + m.group(2) + suffix + ".jar!/")); // NOI18N
                        }
                    } catch (MalformedURLException x) {
                        LOG.log(Level.WARNING, "could not find locale variants of " + jar, x);
                    }
                } else {
                    LOG.log(Level.WARNING, "could not find locale variants of {0}", jar);
                }
                LOG.log(Level.FINE, "from {0} getting {1}", new Object[] {layer, roots});
                return ClassPathSupport.createClassPath(roots.toArray(new URL[roots.size()]));
            }
            Project p;
            try {
                p = FileOwnerQuery.getOwner(layer.toURI());
                if (p != null) {
                    return LayerUtils.findResourceCP(p);
                }
            } catch (URISyntaxException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    }
    LOG.log(Level.WARNING, "no classpath found for {0} @{1}", new Object[] {fo, Arrays.toString(layers)});
    return ClassPathSupport.createClassPath(new URL[0]);
}
项目:incubator-netbeans    文件:SelectConfigFilesPanel.java   
public void run() {
    final Set<File> result = new HashSet<File>();
    // Search in the source groups of the projects.
    for (SourceGroup group : ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
        for (FileObject fo : NbCollections.iterable(group.getRootFolder().getChildren(true))) {
            if (Thread.currentThread().isInterrupted()) {
                return;
            }
            if (!SpringConstants.CONFIG_MIME_TYPE.equals(fo.getMIMEType())) {
                continue;
            }
            File file = FileUtil.toFile(fo);
            if (file == null) {
                continue;
            }
            result.add(file);
        }
    }
    // Search any providers of Spring config files registered in the project lookup.
    for (SpringConfigFileProvider provider : project.getLookup().lookupAll(SpringConfigFileProvider.class)) {
        if (Thread.currentThread().isInterrupted()) {
            return;
        }
        result.addAll(provider.getConfigFiles());
    }
    final List<File> sorted = new ArrayList<File>(result.size());
    sorted.addAll(result);
    Collections.sort(sorted);
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            updateAvailableFiles(sorted);
        }
    });
}
项目:incubator-netbeans    文件:NbBundleProcessor.java   
private void warnUndocumented(int i, Element e, String key) {
    AnnotationMirror mirror = null;
    AnnotationValue value = null;
    if (e != null) {
        for (AnnotationMirror _mirror : e.getAnnotationMirrors()) {
            if (_mirror.getAnnotationType().toString().equals(NbBundle.Messages.class.getCanonicalName())) {
                mirror = _mirror;
                for (Map.Entry<? extends ExecutableElement,? extends AnnotationValue> entry : mirror.getElementValues().entrySet()) {
                    if (entry.getKey().getSimpleName().contentEquals("value")) {
                        // SimpleAnnotationValueVisitor6 unusable here since we need to determine the AnnotationValue in scope when visitString is called:
                        Object v = entry.getValue().getValue();
                        if (v instanceof String) {
                            if (((String) v).startsWith(key + "=")) {
                                value = entry.getValue();
                            }
                        } else {
                            for (AnnotationValue subentry : NbCollections.checkedListByCopy((List<?>) v, AnnotationValue.class, true)) {
                                v = subentry.getValue();
                                if (v instanceof String) {
                                    if (((String) v).startsWith(key + "=")) {
                                        value = subentry;
                                        break;
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
                break;
            }
        }
    }
    processingEnv.getMessager().printMessage(Kind.WARNING, "Undocumented format parameter {" + i + "}", e, mirror, value);
}
项目:incubator-netbeans    文件:NbMavenProjectImpl.java   
public Map<? extends String,? extends String> createSystemPropsForPropertyExpressions() {
    Map<String,String> props = NbCollections.checkedMapByCopy(EmbedderFactory.getProjectEmbedder().getSystemProperties(), String.class, String.class, true);
    ActiveJ2SEPlatformProvider platformProvider = getLookup().lookup(ActiveJ2SEPlatformProvider.class);
    if (platformProvider != null) { // may be null inside PackagingProvider
        props.putAll(platformProvider.getJavaPlatform().getSystemProperties());
    }       
    return props;
}