use of com.intellij.uiDesigner.lw.IProperty in project intellij-community by JetBrains.
the class FormInspectionUtil method getText.
@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;
}
use of com.intellij.uiDesigner.lw.IProperty in project intellij-community by JetBrains.
the class Java15FormInspection method checkComponentProperties.
protected void checkComponentProperties(Module module, final IComponent component, final FormErrorCollector collector) {
final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
final PsiManager psiManager = PsiManager.getInstance(module.getProject());
final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
if (aClass == null) {
return;
}
for (final IProperty prop : component.getModifiedProperties()) {
final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, prop.getName(), false, true);
if (getter == null)
continue;
final LanguageLevel languageLevel = LanguageLevelUtil.getEffectiveLanguageLevel(module);
if (Java15APIUsageInspection.getLastIncompatibleLanguageLevel(getter, languageLevel) != null) {
registerError(component, collector, prop, "@since " + Java15APIUsageInspection.getShortName(languageLevel));
}
}
}
use of com.intellij.uiDesigner.lw.IProperty in project intellij-community by JetBrains.
the class Painter method paintComponentTag.
public static void paintComponentTag(final RadComponent component, final Graphics g) {
if (component instanceof RadContainer)
return;
for (IProperty prop : component.getModifiedProperties()) {
if (prop.getName().equals(SwingProperties.TEXT)) {
final Object desc = prop.getPropertyValue(component);
if (!(desc instanceof StringDescriptor) || ((StringDescriptor) desc).getValue() == null || ((StringDescriptor) desc).getValue().length() > 0) {
return;
}
} else if (prop.getName().equals(SwingProperties.MODEL)) {
// don't paint tags on non-empty lists
final Object value = prop.getPropertyValue(component);
if (value instanceof String[] && ((String[]) value).length > 0) {
return;
}
}
}
Rectangle bounds = component.getDelegee().getBounds();
if (bounds.width > 100 && bounds.height > 40) {
StringBuilder tagBuilder = new StringBuilder();
if (component.getBinding() != null) {
tagBuilder.append(component.getBinding()).append(':');
}
String className = component.getComponentClassName();
int pos = className.lastIndexOf('.');
if (pos >= 0) {
tagBuilder.append(className.substring(pos + 1));
} else {
tagBuilder.append(className);
}
final Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(tagBuilder.toString(), g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(PlatformColors.BLUE);
g2d.fillRect(0, 0, (int) stringBounds.getWidth(), (int) stringBounds.getHeight());
g2d.setColor(JBColor.WHITE);
UISettings.setupAntialiasing(g);
g.drawString(tagBuilder.toString(), 0, g.getFontMetrics().getAscent());
}
}
use of com.intellij.uiDesigner.lw.IProperty in project intellij-community by JetBrains.
the class AssignMnemonicFix method run.
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);
}
}
use of com.intellij.uiDesigner.lw.IProperty in project intellij-community by JetBrains.
the class IntroStringProperty method checkUpdateBindingFromText.
private static void checkUpdateBindingFromText(final RadComponent component, final StringDescriptor value, final SupportCode.TextWithMnemonic textWithMnemonic) {
if (component.isLoadingProperties()) {
return;
}
// only generate binding from text if default locale is active (IDEADEV-9427)
if (value.getValue() == null) {
RadRootContainer root = (RadRootContainer) FormEditingUtil.getRoot(component);
Locale locale = root.getStringDescriptorLocale();
if (locale != null && locale.getDisplayName().length() > 0) {
return;
}
}
BindingProperty.checkCreateBindingFromText(component, textWithMnemonic.myText);
if (component.getDelegee() instanceof JLabel) {
for (IProperty prop : component.getModifiedProperties()) {
if (prop.getName().equals(SwingProperties.LABEL_FOR) && prop instanceof IntroComponentProperty) {
((IntroComponentProperty) prop).updateLabelForBinding(component);
}
}
}
}
Aggregations