Lines 58-69
Link Here
|
58 |
|
58 |
|
59 |
private static class AllContext<TabContext> { |
59 |
private static class AllContext<TabContext> { |
60 |
final String name; |
60 |
final String name; |
|
|
61 |
final String type; |
61 |
final Class<TabContext> tabContextType; |
62 |
final Class<TabContext> tabContextType; |
62 |
final TabContext tabContext; |
63 |
final TabContext tabContext; |
63 |
AllContext(String name, Class<TabContext> tabContextType, TabContext tabContext) { |
64 |
AllContext(String name, String type, Class<TabContext> tabContextType, TabContext tabContext) { |
64 |
this.name = name; |
65 |
this.name = name; |
65 |
this.tabContextType = tabContextType; |
66 |
this.tabContextType = tabContextType; |
66 |
this.tabContext = tabContext; |
67 |
this.tabContext = tabContext; |
|
|
68 |
this.type = type; |
67 |
} |
69 |
} |
68 |
} |
70 |
} |
69 |
|
71 |
|
Lines 76-81
Link Here
|
76 |
private static final Map<InputOutput,AllContext<?>> freeTabs = new WeakHashMap<InputOutput,AllContext<?>>(); |
78 |
private static final Map<InputOutput,AllContext<?>> freeTabs = new WeakHashMap<InputOutput,AllContext<?>>(); |
77 |
|
79 |
|
78 |
protected InputOutput io; |
80 |
protected InputOutput io; |
|
|
81 |
private String type; |
79 |
private final String name; |
82 |
private final String name; |
80 |
|
83 |
|
81 |
protected OutputTabMaintainer(String name) { |
84 |
protected OutputTabMaintainer(String name) { |
Lines 87-93
Link Here
|
87 |
protected final void markFreeTab() { |
90 |
protected final void markFreeTab() { |
88 |
synchronized (freeTabs) { |
91 |
synchronized (freeTabs) { |
89 |
assert io != null; |
92 |
assert io != null; |
90 |
freeTabs.put(io, new AllContext<TabContext>(name, tabContextType(), createContext())); |
93 |
freeTabs.put(io, new AllContext<TabContext>(name, type, tabContextType(), createContext())); |
91 |
} |
94 |
} |
92 |
} |
95 |
} |
93 |
|
96 |
|
Lines 99-118
Link Here
|
99 |
return new Action[0]; |
102 |
return new Action[0]; |
100 |
} |
103 |
} |
101 |
|
104 |
|
102 |
public final InputOutput getInputOutput() { |
105 |
public final InputOutput getInputOutput(String type) { |
103 |
if (io == null) { |
106 |
if (io == null) { |
104 |
io = createInputOutput(); |
107 |
io = createInputOutput(type); |
105 |
} |
108 |
} |
106 |
return io; |
109 |
return io; |
107 |
} |
110 |
} |
108 |
|
111 |
|
109 |
protected final InputOutput createInputOutput() { |
112 |
protected final InputOutput createInputOutput(String type) { |
110 |
synchronized (freeTabs) { |
113 |
synchronized (freeTabs) { |
111 |
for (Map.Entry<InputOutput,AllContext<?>> entry : freeTabs.entrySet()) { |
114 |
for (Map.Entry<InputOutput,AllContext<?>> entry : freeTabs.entrySet()) { |
112 |
InputOutput free = entry.getKey(); |
115 |
InputOutput free = entry.getKey(); |
|
|
116 |
|
113 |
AllContext<?> allContext = entry.getValue(); |
117 |
AllContext<?> allContext = entry.getValue(); |
114 |
if (io == null && allContext.name.equals(name) && allContext.tabContextType == tabContextType()) { |
118 |
if (io == null && allContext.name.equals(name) && allContext.type.equals(type) && allContext.tabContextType == tabContextType()) { |
115 |
// Reuse it. |
119 |
// Reuse it. |
|
|
120 |
this.type = type; |
116 |
io = free; |
121 |
io = free; |
117 |
reassignAdditionalContext(tabContextType().cast(allContext.tabContext)); |
122 |
reassignAdditionalContext(tabContextType().cast(allContext.tabContext)); |
118 |
try { |
123 |
try { |
Lines 130-136
Link Here
|
130 |
} |
135 |
} |
131 |
// } |
136 |
// } |
132 |
if (io == null) { |
137 |
if (io == null) { |
133 |
io = IOProvider.getDefault().getIO(name, createNewTabActions()); |
138 |
IOProvider provider = type == null ? IOProvider.getDefault() : IOProvider.get(type); |
|
|
139 |
this.type = type; |
140 |
io = provider.getIO(name, createNewTabActions()); |
141 |
|
134 |
io.setInputVisible(true); |
142 |
io.setInputVisible(true); |
135 |
} |
143 |
} |
136 |
return io; |
144 |
return io; |