Пример #1
0
def get_preference(path, key, default=None):
    """
    """
    service = Platform.getPreferencesService()
    root = service.getRootNode()
    pref = root.node(path)
    return pref.get(key, default)
Пример #2
0
def __getPluginPath__(plugin):
    """ Get path to classes in plugin (if running under Eclipse)
        @param plugin Plugin ID
        @return Path to the classes in the plugin, or None
    """
    try:
        # Under Eclipse, should be able to locate the bundle
        from org.eclipse.core.runtime import Platform
        from org.eclipse.core.runtime import FileLocator
        from org.eclipse.core.runtime import Path
        bundle = Platform.getBundle(plugin)
        # While in the IDE, the classes are in a bin subdir
        url = FileLocator.find(bundle, Path("bin"), None)
        if url:
            return FileLocator.resolve(url).getPath()
        # In an exported product, the classes are
        # at the root of the jar or the expanded
        # plugin directory
        return FileLocator.getBundleFile(bundle).getPath()
    except:
        # Not running under Eclipse
        return None
def __getPluginPath__(plugin):
    """ Get path to classes in plugin (if running under Eclipse)
        @param plugin Plugin ID
        @return Path to the classes in the plugin, or None
    """
    try:
        # Under Eclipse, should be able to locate the bundle
        from org.eclipse.core.runtime import Platform
        from org.eclipse.core.runtime import FileLocator
        from org.eclipse.core.runtime import Path
        bundle = Platform.getBundle(plugin)
        # While in the IDE, the classes are in a bin subdir
        url = FileLocator.find(bundle, Path("bin"), None)
        if url:
            return FileLocator.resolve(url).getPath()
        # In an exported product, the classes are
        # at the root of the jar or the expanded
        # plugin directory
        return FileLocator.getBundleFile(bundle).getPath()
    except:
        # Not running under Eclipse
        return None
Пример #4
0
def set_preference(path, key, value, type="string"):
    """ Set a preference.
    
    http://help.eclipse.org/galileo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/preferences/package-summary.html
    
    NOTE: Workbench must be restarted to make changes effective - 
    looks like Preference dialog keeps its own cached copy of preference somewhere and ignores changes here.  
    """
    service = Platform.getPreferencesService()
    root = service.getRootNode()
    pref = root.node(path)    

    # Java and static typing bites here...
    if type=="string":
        pref.put(key, value)
    elif type=="boolean":
        pref.putBoolean(key, value)
    elif type=="integer":
        pref.putInt(key, value)
    else:
        raise RuntimeError("Unknown type:" + type)
    
    pref.flush()
Пример #5
0
    # Fall back to original numpy
    from numpy import *
else:
    try:
        # If this succeeds, the binaries are already in the classpath
        # (set on command line, or running within scan server)
        import org.csstudio.ndarray.NDArray as NDArray
    except:
        # Need to locate NDArray binaries
        try:
            # When running under Eclipse, locate org.epics.util and NDArray bundle
            from org.eclipse.core.runtime import Platform
            from org.eclipse.core.runtime import FileLocator
            from org.eclipse.core.runtime import Path
            
            bundle = Platform.getBundle("org.epics.util")
            url = FileLocator.find(bundle, Path("bin"), None)
            if url:
                # While in the IDE, the plugin classes are in a bin subdir
                sys.path.append(FileLocator.resolve(url).getPath())
            else:
                # In an exported product, the classes are at the root
                sys.path.append(FileLocator.getBundleFile(bundle).getPath())
            
            bundle = Platform.getBundle("org.csstudio.ndarray")
            url = FileLocator.find(bundle, Path("bin"), None)
            if url:
                sys.path.append(FileLocator.resolve(url).getPath())
            else:
                sys.path.append(FileLocator.getBundleFile(bundle).getPath())
        except:
Пример #6
0
        
    print preference.absolutePath() + " dumping"
    
    print preference.__class__
        
    dump_keys(preference)
        
    for child_name in preference.childrenNames():
        #print "Got:" + child_name
        
        if child_name.startswith("_") or child_name == preference.name():
            # Looks like there is magical node _SELF_
            continue
                    
        child = preference.node(child_name)
        #continue
        
        #print child.childrenNames()
        #dump_keys(child)        
        dump_preference(child)
    

service = Platform.getPreferencesService()
root = service.getRootNode()
dump_preference(root)
    

    
    
    
Пример #7
0
# Path setup
import sys, os

try:
    # If this succeeds, the binaries are already in the classpath
    # (set on command line, or running within scan server)
    import org.csstudio.ndarray.NDArray as NDArray
except:
    # Need to locate NDArray binaries
    try:
        # When running under Eclipse, locate org.epics.util and NDArray bundle
        from org.eclipse.core.runtime import Platform
        from org.eclipse.core.runtime import FileLocator
        from org.eclipse.core.runtime import Path
        
        bundle = Platform.getBundle("org.epics.util")
        url = FileLocator.find(bundle, Path("bin"), None)
        if url:
            # While in the IDE, the plugin classes are in a bin subdir
            sys.path.append(FileLocator.resolve(url).getPath())
        else:
            # In an exported product, the classes are at the root
            sys.path.append(FileLocator.getBundleFile(bundle).getPath())
        
        bundle = Platform.getBundle("org.csstudio.ndarray")
        url = FileLocator.find(bundle, Path("bin"), None)
        if url:
            sys.path.append(FileLocator.resolve(url).getPath())
        else:
            sys.path.append(FileLocator.getBundleFile(bundle).getPath())
    except: