BIMInspectorTool.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * BIMInspectorTool.js
  3. *
  4. * @author realor
  5. */
  6. import { Tool } from './Tool.js'
  7. import { Dialog } from '../ui/Dialog.js'
  8. import { MessageDialog } from '../ui/MessageDialog.js'
  9. import { I18N } from '../i18n/I18N.js'
  10. class BIMInspectorTool extends Tool {
  11. constructor(application, options) {
  12. super(application)
  13. this.name = 'bim_inspector'
  14. this.label = 'bim|tool.bim_inspector.label'
  15. this.help = 'bim|tool.bim_inspector.help'
  16. this.className = 'bim_inspector'
  17. this.immediate = true
  18. this.setOptions(options)
  19. }
  20. execute() {
  21. const application = this.application
  22. const object = application.selection.object
  23. if (object && object._ifc) {
  24. const replacer = (key, value) => {
  25. return key === '_helper' ? undefined : value
  26. }
  27. const json = JSON.stringify(object._ifc, replacer, 2)
  28. const dialog = new Dialog(this.label)
  29. dialog.setSize(600, 500)
  30. dialog.setI18N(application.i18n)
  31. dialog.addCode(json)
  32. let button = dialog.addButton('accept', 'button.accept', () => dialog.hide())
  33. dialog.onShow = () => button.focus()
  34. dialog.show()
  35. } else {
  36. MessageDialog.create(this.label, 'bim|message.no_bim_object_selected')
  37. .setClassName('info')
  38. .setI18N(application.i18n)
  39. .show()
  40. }
  41. }
  42. }
  43. export { BIMInspectorTool }