J'utilise Google Window Builder Pro pour SWT et nous utilisons beaucoup de composants personnalisés ici. Les composants reposent sur l'utilisation dans notre framework, mais cela les rend inutilisables dans Window Builder (les exeptions sont lancées lorsqu'elles sont utilisées en dehors de notre framework, comme dans Window Builder). Comment puis-je détecter que Window Builder utilise nos composants pour ignorer le code qui repose sur notre infrastructure?Detect Window Builder
1
A
Répondre
2
J'ai implémenté une fonction utilitaire qui vide un StackTrace et recherche des éléments dans les instanciations qu'il contient. Cela fonctionne parfaitement:
/**
* Designer mode. This is used to detect if the widgets are running
* from SWT designer, because in this case we have to skip some
* initialization code.
*/
private static Boolean designerMode;
/**
* This is used to detect if the widgets are running
* from SWT designer, because in this case we have to skip some
* initialization code.
*/
public static boolean isDesignerMode() {
if(designerMode == null) {
String s = StacktraceUtils.getStackTraceAsString(
new RuntimeException("Just to get the Stacktrace."));
designerMode = s.contains("com.instantiations.designer");
}
return designerMode;
}
1
Vous pouvez imprimer la Stacktrace sous forme de chaîne de cette façon (la méthode getStackTraceAsString() est absent de la réponse de Daniel):
public static String getStackTraceAsString(Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
return sw.toString(); // stack trace as a string
}
Questions connexes
- 1. Detect framework version 3.5
- 2. Detect SQL Injection
- 3. .net DETECT distribués transaction
- 4. Facebook staticFBML detect fan
- 5. Iphone detect Région Format
- 6. javascript detect # in url
- 7. Detect FlowDocument Changement et défilement
- 8. matériel GPS DETECT dans iphone
- 9. DETECT actuellement installé anti-virus
- 10. Detect KITL lors de l'exécution
- 11. window singleton
- 12. java, client detect serveur est décédé
- 13. Detect charset à distance en php
- 14. Detect Lorsque Efficacement Sibling éléments Overlap
- 15. Detect langues prises en charge mobiles
- 16. window télécharger java
- 17. javascript window décharger l'événement
- 18. WPF Window LocationChanged terminé
- 19. PrintPreview Window in C#
- 20. inherit gtkmm window class
- 21. Get Tkinter Window Size
- 22. Asp.Net: Javascript Modal Window
- 23. OpenGL cross platform window
- 24. wxWidgets Get Window
- 25. WPF Window Docking
- 26. Python Win32GUI Find Window
- 27. javascript window events
- 28. Javascript Popup Window
- 29. WPF Window Position
- 30. Implémenter Hann Window