|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.i18n.wizard; import java.util.*; import org.netbeans.modules.i18n.FactoryRegistry; import org.netbeans.modules.i18n.I18nUtil; import org.netbeans.modules.properties.PropertiesDataObject; import org.netbeans.api.java.classpath.GlobalPathRegistry; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.project.Project; import org.netbeans.spi.project.ui.support.LogicalViews; import org.openide.loaders.DataFolder; import org.openide.loaders.DataObject; import org.openide.loaders.DataObjectNotFoundException; import org.openide.loaders.DataFilter; import org.openide.nodes.Node; import org.openide.nodes.Children; import org.openide.nodes.AbstractNode; import org.openide.nodes.FilterNode; import org.openide.util.*; import org.openide.cookies.EditorCookie; import org.openide.filesystems.FileObject; import org.netbeans.api.project.FileOwnerQuery; /** * Bundle access, ... * * @author Petr Kuzel */ final class Util extends org.netbeans.modules.i18n.Util { public static String getString(String key) { return NbBundle.getMessage(org.netbeans.modules.i18n.wizard.Util.class, key); } public static char getChar(String key) { return getString(key).charAt(0); } // Settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create empty settings used in i18n wizards. */ public static Map createWizardSourceMap() { return new TreeMap(new DataObjectComparator()); } /** * Create settings based on selected nodes. Finds all accepted data objects. * Used by actions to populate wizard. * @param activatedNodes selected nodes * @return map with accepted data objects as keys or empty map if no such * data objec were found. */ public static Map createWizardSourceMap(Node[] activatedNodes) { Map sourceMap = createWizardSourceMap(); if (activatedNodes != null && activatedNodes.length > 0) { for (int i = 0; i < activatedNodes.length; i++) { DataObject.Container container = (DataObject.Container) activatedNodes[i].getCookie(DataObject.Container.class); if (container != null) { Iterator it = I18nUtil.getAcceptedDataObjects(container).iterator(); while(it.hasNext()) { addSource(sourceMap, (DataObject)it.next()); } } DataObject dobj = (DataObject) activatedNodes[i].getCookie(DataObject.class); if (dobj == null) continue; if (FactoryRegistry.hasFactory(dobj.getClass())) { addSource(sourceMap, dobj); } } } return sourceMap; } /** Adds source to source map (I18N wizard settings). If there is already no change is done. * If it's added anew then it is tried to find correspondin reousrce, i.e. * first resource from the same folder. * @param sourceMap settings where to add teh sources * @param source source to add */ public static void addSource(Map sourceMap, DataObject source) { if(sourceMap.containsKey(source)) return; DataFolder folder = source.getFolder(); if(folder == null) { sourceMap.put(source, null); return; } // try to associate Bundle file DataObject[] children = folder.getChildren(); for(int i = 0; i < children.length; i++) { if(children[i] instanceof PropertiesDataObject) { // PENDING sourceMap.put(source, new SourceData(children[i])); return; } } // No resource found in the same folder. sourceMap.put(source, null); } /** Shared enableness logic. Either DataObject.Container or EditorCookie must be present on all nodes.*/ static boolean wizardEnabled(Node[] activatedNodes) { if (activatedNodes == null || activatedNodes.length == 0) { return false; } for (int i = 0; i |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.