Revision 981 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/java/org/gvsig/scripting/impl/AbstractUnit.java

View differences:

AbstractUnit.java
6 6
import java.io.IOException;
7 7
import java.util.HashMap;
8 8
import java.util.HashSet;
9
import java.util.List;
9 10
import java.util.Map;
10 11
import java.util.Set;
12
import java.util.logging.Level;
11 13

  
12 14
import org.ini4j.Ini;
13 15
import org.slf4j.Logger;
......
83 85
    public abstract void load(ScriptingFolder folder, String id);
84 86

  
85 87
    @Override
88
    public void reload() {
89
        this.load( this.getParent(), this.getId());
90
    }
91
    
92
    @Override
86 93
    public String toString() {
87 94
        if (this.getName() == null) {
88 95
            return "(" + this.getClass().getSimpleName() + ")";
......
309 316
        return this.properties.get(name);
310 317
    }
311 318
    
319
    @Override
312 320
    public Map<String,String> getProperties() {
313 321
        return this.properties;
314 322
    }
323

  
324
    @Override
325
    public boolean isASystemUnit() {
326
        String pathUnit;
327
        try {
328
            pathUnit = this.getParent().getFile().getCanonicalPath();
329
        } catch (IOException ex) {
330
            pathUnit = this.getParent().getFile().getAbsolutePath();
331
        }
332
        if( !pathUnit.endsWith(File.separator) ) {
333
            pathUnit = pathUnit + File.separator;
334
        }
335
        List<File> libs = this.getManager().getLibFolders();
336
        for( File lib : libs ) {
337
            String pathLib;
338
            try {
339
                pathLib = lib.getCanonicalPath();
340
            } catch (IOException ex) {
341
                pathLib = lib.getAbsolutePath();
342
            }
343
            if( !pathLib.endsWith(File.separator) ) {
344
                pathLib = pathLib + File.separator;
345
            }
346
            if( pathUnit.startsWith(pathLib) ) {
347
                return true;
348
            }
349
        }
350
        return false;
351
    }
315 352
    
316 353
}

Also available in: Unified diff