Revision 739 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/main/java/org/gvsig/scripting/swing/impl/DefaultScriptingUIManager.java
DefaultScriptingUIManager.java | ||
---|---|---|
75 | 75 |
private final Map<String,MenuEntry> composerMenus = new HashMap<>(); |
76 | 76 |
private JScriptingComposer activeComposer; |
77 | 77 |
private Set<CreateComponentListener> createComponentListeners; |
78 |
private final List<EditorFactory> editorFactories = new ArrayList<>(); |
|
78 |
private final Map<String,EditorFactory> editorFactories = new HashMap<>(); |
|
79 |
private List<EditorFactory> editorFactoriesOrderer = null; |
|
79 | 80 |
|
80 | 81 |
private static class DefaultMenuEntry implements MenuEntry { |
81 | 82 |
private final Action action; |
... | ... | |
399 | 400 |
@Override |
400 | 401 |
public JEditor createEditor(ScriptingUnit unit) { |
401 | 402 |
JEditor editor = null; |
402 |
for (EditorFactory factory : this.editorFactories ) {
|
|
403 |
for (EditorFactory factory : this.getEditorFactories() ) {
|
|
403 | 404 |
if( factory.canCreate(unit) ) { |
404 | 405 |
editor = factory.create(unit); |
405 | 406 |
fireCreateComponent(editor); |
... | ... | |
409 | 410 |
return editor; |
410 | 411 |
} |
411 | 412 |
|
413 |
@Override |
|
412 | 414 |
public boolean hasEditor(ScriptingUnit unit) { |
413 |
for (EditorFactory factory : this.editorFactories ) {
|
|
415 |
for (EditorFactory factory : this.getEditorFactories() ) {
|
|
414 | 416 |
if( factory.canCreate(unit) ) { |
415 | 417 |
return true; |
416 | 418 |
} |
... | ... | |
427 | 429 |
return this.activeComposer; |
428 | 430 |
} |
429 | 431 |
|
432 |
@Override |
|
430 | 433 |
public void registerEditor(EditorFactory factory) { |
431 |
if( this.editorFactories.contains(factory) ) { |
|
432 |
return; |
|
434 |
this.editorFactories.put(factory.getName(), factory); |
|
435 |
this.editorFactoriesOrderer = null; |
|
436 |
} |
|
437 |
|
|
438 |
@Override |
|
439 |
public List<EditorFactory> getEditorFactories() { |
|
440 |
if( this.editorFactoriesOrderer == null ) { |
|
441 |
this.editorFactoriesOrderer = new ArrayList<>(this.editorFactories.values()); |
|
442 |
Collections.sort(editorFactoriesOrderer, new Comparator<EditorFactory>() { |
|
443 |
|
|
444 |
@Override |
|
445 |
public int compare(EditorFactory o1, EditorFactory o2) { |
|
446 |
return o2.getPriority() - o1.getPriority(); |
|
447 |
} |
|
448 |
}); |
|
433 | 449 |
} |
434 |
this.editorFactories.add(factory); |
|
435 |
Collections.sort(editorFactories, new Comparator<EditorFactory>() { |
|
436 |
|
|
437 |
@Override |
|
438 |
public int compare(EditorFactory o1, EditorFactory o2) { |
|
439 |
return o2.getPriority() - o1.getPriority(); |
|
440 |
} |
|
441 |
}); |
|
450 |
return editorFactoriesOrderer; |
|
442 | 451 |
} |
443 | 452 |
} |
Also available in: Unified diff