@Nullable public static SupportCode.TextWithMnemonic getTextWithMnemonic(final Module module, final IComponent component) { if (module.isDisposed()) return null; IProperty prop = FormInspectionUtil.findProperty(component, SwingProperties.TEXT); if (prop != null) { Object propValue = prop.getPropertyValue(component); if (propValue instanceof StringDescriptor) { StringDescriptor descriptor = (StringDescriptor)propValue; String value; if (component instanceof RadComponent) { value = StringDescriptorManager.getInstance(module).resolve((RadComponent) component, descriptor); } else { value = StringDescriptorManager.getInstance(module).resolve(descriptor, null); } SupportCode.TextWithMnemonic twm = SupportCode.parseText(value); if (twm.myMnemonicIndex >= 0 && (FormInspectionUtil.isComponentClass(module, component, JLabel.class) || FormInspectionUtil.isComponentClass(module, component, AbstractButton.class))) { return twm; } } } return null; }
@Nullable public static String getText(@NotNull final Module module, final IComponent component) { IProperty textProperty = findProperty(component, SwingProperties.TEXT); if (textProperty != null) { Object propValue = textProperty.getPropertyValue(component); String value = null; if (propValue instanceof StringDescriptor) { StringDescriptor descriptor = (StringDescriptor) propValue; if (component instanceof RadComponent) { value = StringDescriptorManager.getInstance(module).resolve((RadComponent) component, descriptor); } else { value = StringDescriptorManager.getInstance(module).resolve(descriptor, null); } } else if (propValue instanceof String) { value = (String) propValue; } if (value != null) { return value; } } return null; }
public StringDescriptor getValue(final RadContainer component) { final StringDescriptor descriptor = component.getBorderTitle(); final String resolvedValue = StringDescriptorManager.getInstance(component.getModule()).resolve(component, descriptor); if (descriptor != null) { descriptor.setResolvedValue(resolvedValue); } return descriptor; }
protected void setValueImpl(final RadContainer component, final StringDescriptor value) throws Exception { StringDescriptor title = value; if (title != null && StringDescriptorManager.getInstance(component.getModule()).resolve(component, title).length() == 0) { title = null; } component.setBorderTitle(title); }
public void showResourceBundleDescriptor(@NotNull final StringDescriptor descriptor) { final String key = descriptor.getKey(); LOG.assertTrue(key != null); myTfBundleName.setText(descriptor.getBundleName()); myTfKey.setText(key); myTfRbValue.setText(StringDescriptorManager.getInstance(myEditor.getModule()).resolve(descriptor, myLocale)); }
public void run() { IProperty textProperty = FormInspectionUtil.findProperty(myComponent, SwingProperties.TEXT); StringDescriptor descriptor = (StringDescriptor) textProperty.getPropertyValue(myComponent); String value = StringDescriptorManager.getInstance(myComponent.getModule()).resolve(myComponent, descriptor); String[] variants = fillMnemonicVariants(SupportCode.parseText(value).myText); String result = Messages.showEditableChooseDialog(UIDesignerBundle.message("inspection.missing.mnemonics.quickfix.prompt"), UIDesignerBundle.message("inspection.missing.mnemonics.quickfix.title"), Messages.getQuestionIcon(), variants, variants [0], null); if (result != null) { if (!myEditor.ensureEditable()) { return; } FormInspectionUtil.updateStringPropertyValue(myEditor, myComponent, (IntroStringProperty)textProperty, descriptor, result); } }
public void showStringDescriptor(@Nullable final StringDescriptor descriptor) { myTfValue.setText(StringDescriptorManager.getInstance(myEditor.getModule()).resolve(descriptor, myLocale)); myNoI18nCheckbox.setSelected(descriptor != null && descriptor.isNoI18n()); }