public void setContent(final FieldProvider fieldProvider) {
   String dialog = "";
   if (fieldProvider instanceof SpellLevel) {
     dialog = "spellDetailPopup";
     this.m_property = "describedSpell";
   } else if (fieldProvider instanceof Item
       || fieldProvider instanceof ReferenceItem
       || fieldProvider instanceof MerchantInventoryItem
       || fieldProvider instanceof ReferenceItemFieldProvider) {
     Item item = null;
     ReferenceItem refItem;
     if (fieldProvider instanceof Item) {
       refItem = (ReferenceItem) ((Item) fieldProvider).getReferenceItem();
       item = (Item) fieldProvider;
     } else if (fieldProvider instanceof ReferenceItem) {
       refItem = (ReferenceItem) fieldProvider;
     } else if (fieldProvider instanceof MerchantInventoryItem) {
       refItem =
           (ReferenceItem) ((MerchantInventoryItem) fieldProvider).getItem().getReferenceItem();
     } else {
       if (!(fieldProvider instanceof ReferenceItemFieldProvider)) {
         return;
       }
       refItem = ((ReferenceItemFieldProvider) fieldProvider).getReferenceItem();
     }
     final ReferenceItemDisplayer refItemDisplayer = refItem.getReferenceItemDisplayer();
     final ArrayList<String> characteristicsDesc = refItemDisplayer.getCharacteristicsString();
     final ArrayList<String> effectsDesc = refItemDisplayer.getEffectsString();
     if (effectsDesc == null && characteristicsDesc == null) {
       dialog = "itemSimplePopup";
     } else {
       dialog = "itemDetailPopup";
     }
     this.m_property = "itemPopupDetail";
   } else if (fieldProvider instanceof Skill) {
     dialog = "skillDescription2";
   }
   if (this.m_property != null
       && !this.m_property.isEmpty()
       && fieldProvider != null
       && !fieldProvider.equals(
           PropertiesProvider.getInstance().getObjectProperty(this.m_property))) {
     PropertiesProvider.getInstance().setPropertyValue(this.m_property, fieldProvider);
   }
   if (!dialog.isEmpty() && !dialog.equals(this.m_lastDialog)) {
     final ElementMap map =
         Xulor.getInstance().getEnvironment().getElementMap("worldAndFightBarDialog");
     if (map != null) {
       this.m_popupDialog = (PopupElement) map.getElement(dialog);
     }
     this.m_lastDialog = dialog;
   }
 }
 @Override
 public boolean onMessage(final Message message) {
   if (message instanceof ClockMessage) {
     final ClockMessage clockMessage = (ClockMessage) message;
     MessageScheduler.getInstance().removeClock(clockMessage.getClockId());
     if (this.m_cancelTimedPop) {
       return false;
     }
     this.popup();
     return false;
   } else {
     switch (message.getId()) {
       case 19301:
         {
           final UIShowPopupInfosMessage msg = (UIShowPopupInfosMessage) message;
           boolean ok = false;
           if (this.m_popupDialog == null || this.m_fieldProvider == null) {
             MessageScheduler.getInstance().removeAllClocks(this);
             return false;
           }
           if (this.m_fieldProvider instanceof SpellLevel
               && msg.getContent() instanceof SpellLevel) {
             final SpellLevel spellLevel1 = (SpellLevel) this.m_fieldProvider;
             final SpellLevel spellLevel2 = (SpellLevel) msg.getContent();
             ok = (spellLevel1.getSpell().getId() == spellLevel2.getSpell().getId());
           } else {
             ok = this.m_fieldProvider.equals(msg.getContent());
           }
           if (ok) {
             this.m_cancelTimedPop = !XulorActions.closePopup(null, this.m_popupDialog);
             PropertiesProvider.getInstance().removeProperty(this.m_property);
           }
           return false;
         }
       case 19300:
         {
           final UIShowPopupInfosMessage msg = (UIShowPopupInfosMessage) message;
           this.m_fieldProvider = msg.getContent();
           if (this.m_fieldProvider == null) {
             return false;
           }
           if (msg.getIntValue() > 0) {
             this.m_cancelTimedPop = false;
             MessageScheduler.getInstance().addClock(this, msg.getIntValue(), -1, 1);
           } else {
             this.popup();
           }
           return false;
         }
       default:
         {
           return true;
         }
     }
   }
 }
 public static void selectResElement(final Event e, final ElementFilterView elementFilterView) {
   final ToggleButton button = e.getCurrentTarget();
   elementFilterView.setSelected(button.getSelected());
   final SelectItemElementsView elementsView = SelectItemElementsView.INSTANCE;
   if (elementsView.tooManyChoices(SelectItemElementsView.RES_ACTION_ID)) {
     elementFilterView.setSelected(false);
     button.setSelected(false);
   }
   PropertiesProvider.getInstance().firePropertyValueChanged(elementsView, "checkedResNbElements");
 }
 public static void validNameFilter(final Event event, final TextEditor textEditor) {
   final CraftView craftView =
       (CraftView)
           PropertiesProvider.getInstance()
               .getObjectProperty("craft", event.getTarget().getElementMap().getId());
   final String text = textEditor.getText();
   if (!text.equals(craftView.getNameFilter())) {
     craftView.setNameFilter(text);
   }
 }
 public static void onCraftTypeChanged(final SelectionChangedEvent e, final CraftView view) {
   final byte id = (byte) (e.isSelected() ? 0 : 1);
   view.setCurrentType(CraftType.getFromId(id));
   PropertiesProvider.getInstance().setPropertyValue("craftDisplayType", id);
 }
 public static void checkLevelSorter(final Event event) {
   ((CraftView)
           PropertiesProvider.getInstance()
               .getObjectProperty("craft", event.getTarget().getElementMap().getId()))
       .toggleLevelSorter();
 }
 public static void openLinkedBook(final Event event) {
   ((CraftView)
           PropertiesProvider.getInstance()
               .getObjectProperty("craft", event.getTarget().getElementMap().getId()))
       .displayBook();
 }