|
50 | 50 | import org.jetbrains.annotations.Nullable;
|
51 | 51 |
|
52 | 52 | import java.lang.reflect.Field;
|
| 53 | +import java.lang.reflect.InvocationTargetException; |
| 54 | +import java.lang.reflect.Method; |
53 | 55 | import java.util.ArrayList;
|
54 | 56 | import java.util.Arrays;
|
55 | 57 | import java.util.List;
|
@@ -156,14 +158,31 @@ protected RunContentDescriptor launch(@NotNull ExecutionEnvironment env) throws
|
156 | 158 | else {
|
157 | 159 | descriptor = new RunContentBuilder(result, env).showRunContent(env.getContentToReuse());
|
158 | 160 | }
|
| 161 | + final String nameWithDeviceName = descriptor.getDisplayName() + " (" + device.deviceName() + ")"; |
| 162 | + boolean displayNameUpdated = false; |
159 | 163 | try {
|
160 |
| - final Field f = descriptor.getClass().getDeclaredField("myDisplayName"); |
| 164 | + final Field f = descriptor.getClass().getDeclaredField("myDisplayNameView"); |
161 | 165 | f.setAccessible(true);
|
162 |
| - f.set(descriptor, descriptor.getDisplayName() + " (" + device.deviceName() + ")"); |
| 166 | + Object viewInstance = f.get(descriptor); |
| 167 | + if (viewInstance != null) { |
| 168 | + final Method setValueMethod = viewInstance.getClass().getMethod("setValue", Object.class); |
| 169 | + setValueMethod.invoke(viewInstance, nameWithDeviceName); |
| 170 | + displayNameUpdated = true; |
| 171 | + } |
163 | 172 | }
|
164 |
| - catch (IllegalAccessException | NoSuchFieldException e) { |
| 173 | + catch (ClassCastException | IllegalAccessException | InvocationTargetException | NoSuchFieldException | NoSuchMethodException e) { |
165 | 174 | LOG.info(e);
|
166 | 175 | }
|
| 176 | + if (!displayNameUpdated) { |
| 177 | + try { |
| 178 | + final Field f = descriptor.getClass().getDeclaredField("myDisplayName"); |
| 179 | + f.setAccessible(true); |
| 180 | + f.set(descriptor, nameWithDeviceName); |
| 181 | + } |
| 182 | + catch (IllegalAccessException | NoSuchFieldException e) { |
| 183 | + LOG.info(e); |
| 184 | + } |
| 185 | + } |
167 | 186 | return descriptor;
|
168 | 187 | }
|
169 | 188 |
|
|
0 commit comments