Java Code Examples for com.intellij.codeInsight.lookup.LookupElementPresentation#setIcon()

The following examples show how to use com.intellij.codeInsight.lookup.LookupElementPresentation#setIcon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DoctrineEntityLookupElement.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {

        if(this.useClassNameAsLookupString) {
            presentation.setItemText(className.getPresentableFQN());
            presentation.setTypeText(getLookupString());
        } else {
            presentation.setItemText(getLookupString());
            presentation.setTypeText(className.getPresentableFQN());
        }

        presentation.setTypeGrayed(true);
        if(isWeak) {
            // @TODO: remove weak
            presentation.setIcon(getWeakIcon());
        } else {
            presentation.setIcon(getIcon());
        }


    }
 
Example 2
Source File: ParameterLookupElement.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(containerParameter.getName());

    String value = containerParameter.getValue();
    if(value != null && StringUtils.isNotBlank(value)) {
        presentation.setTypeText(value);
    }

    presentation.setTypeGrayed(true);
    presentation.setIcon(Symfony2Icons.PARAMETER);

    if(this.containerParameter.isWeak()) {
        presentation.setIcon(Symfony2Icons.PARAMETER_OPACITY);
    }

}
 
Example 3
Source File: JsonParseUtil.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
public static void decorateLookupElement(@NotNull LookupElementPresentation lookupElement, @NotNull JsonRawLookupElement jsonLookup) {

        if(jsonLookup.getTailText() != null) {
            lookupElement.setTailText(jsonLookup.getTailText(), true);
        }

        if(jsonLookup.getTypeText() != null) {
            lookupElement.setTypeText(jsonLookup.getTypeText());
            lookupElement.setTypeGrayed(true);
        }

        String iconString = jsonLookup.getIcon();
        if(iconString != null) {
            Icon icon = getLookupIconOnString(iconString);
            if(icon != null) {
                lookupElement.setIcon(icon);
            }
        }

    }
 
Example 4
Source File: TwigExtensionLookupElement.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Override
public void renderElement(LookupElementPresentation presentation) {
    presentation.setIcon(TwigExtensionParser.getIcon(this.twigExtension.getTwigExtensionType()));

    buildTailText(presentation);

    presentation.setItemText(name);
    presentation.setTypeText(StringUtils.camelize(this.twigExtension.getType().toLowerCase()));
    presentation.setTypeGrayed(true);
}
 
Example 5
Source File: ServiceStringLookupElement.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(getLookupString());
    presentation.setTypeGrayed(true);

    String className = getClassName(containerService);
    if(className != null) {
        presentation.setTypeText(StringUtils.strip(className, "\\"));
    }

    // private or non container services
    if(className == null || containerService.isWeak()) {
        presentation.setIcon(Symfony2Icons.SERVICE_OPACITY);
    } else {
        presentation.setIcon(Symfony2Icons.SERVICE);
    }

    if(this.containerService.isPrivate()) {
        presentation.setIcon(Symfony2Icons.SERVICE_PRIVATE_OPACITY);
    }

    presentation.setItemTextBold(this.boldText);
    if(this.boldText) {
        presentation.setTypeGrayed(false);
        presentation.setItemTextUnderlined(true);
    }

    if(containerService.getService() != null) {
        presentation.setStrikeout(containerService.getService().isDeprecated());
    }
}
 
Example 6
Source File: MessageLookupElement.java    From yiistorm with MIT License 5 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(title);


    presentation.setIcon(icon);
    presentation.setTypeText(langTitle);
    presentation.setTypeGrayed(false);
}
 
Example 7
Source File: SymfonyBundleFileLookupElement.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(getLookupString());
    presentation.setTypeText(this.bundleFile.getSymfonyBundle().getName());
    presentation.setTypeGrayed(true);
    presentation.setIcon(IconUtil.getIcon(this.bundleFile.getVirtualFile(), 0, this.bundleFile.getProject()));

}
 
Example 8
Source File: HaxeLookupElement.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Override
public void renderElement(LookupElementPresentation presentation) {
  final ItemPresentation myComponentNamePresentation = myComponentName.getPresentation();
  if (myComponentNamePresentation == null) {
    presentation.setItemText(getLookupString());
    return;
  }

  String presentableText = myComponentNamePresentation.getPresentableText();

  // Check for members: methods and fields
  HaxeBaseMemberModel model = HaxeBaseMemberModel.fromPsi(myComponentName);

  if (model != null) {
    // TODO: Specialization support required
    presentableText = model.getPresentableText(context);

    // Check deprecated modifiers
    if (model instanceof HaxeMemberModel && ((HaxeMemberModel)model).getModifiers().hasModifier(HaxePsiModifier.DEPRECATED)) {
      presentation.setStrikeout(true);
    }

    // Check for non-inherited members to highlight them as intellij-java does
    // @TODO: Self members should be displayed first!
    if (leftReference != null) {
      if (model.getDeclaringClass().getPsi() == leftReference.getHaxeClass()) {
        presentation.setItemTextBold(true);
      }
    }
  }

  presentation.setItemText(presentableText);
  presentation.setIcon(myComponentNamePresentation.getIcon(true));
  final String pkg = myComponentNamePresentation.getLocationString();
  if (StringUtil.isNotEmpty(pkg)) {
    presentation.setTailText(" " + pkg, true);
  }
}
 
Example 9
Source File: GLSLCompletionContributor.java    From glsl4idea with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderElement(LookupElementPresentation presentation) {
    super.renderElement(presentation);
    presentation.setIcon(GLSLSupportLoader.GLSL.getIcon());

    if (type != null) {
        presentation.setTypeText(this.type.getTypename());
    }
}
 
Example 10
Source File: ExistLangFileLookupElement.java    From yiistorm with MIT License 5 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(title);
    ImageIcon icon = new ImageIcon(this.getClass().getResource("/com/yiistorm/images/yii.png"));
    presentation.setIcon(icon);
    presentation.setTypeText(createTitle);
    presentation.setTypeGrayed(false);
}
 
Example 11
Source File: Suggestion.java    From intellij-spring-assistant with MIT License 5 votes vote down vote up
public void renderElement(LookupElement element, LookupElementPresentation presentation) {
  Suggestion suggestion = (Suggestion) element.getObject();
  if (suggestion.icon != null) {
    presentation.setIcon(suggestion.icon);
  }

  presentation.setStrikeout(suggestion.deprecationLevel != null);
  if (suggestion.deprecationLevel != null) {
    if (suggestion.deprecationLevel == SpringConfigurationMetadataDeprecationLevel.error) {
      presentation.setItemTextForeground(RED);
    } else {
      presentation.setItemTextForeground(YELLOW);
    }
  }

  String lookupString = element.getLookupString();
  presentation.setItemText(lookupString);
  if (!lookupString.equals(suggestion.suggestionToDisplay)) {
    presentation.setItemTextBold(true);
  }

  String shortDescription;
  if (suggestion.defaultValue != null) {
    shortDescription = shortenTextWithEllipsis(suggestion.defaultValue, 60, 0, true);
    TextAttributes attrs =
        EditorColorsManager.getInstance().getGlobalScheme().getAttributes(SCALAR_TEXT);
    presentation.setTailText("=" + shortDescription, attrs.getForegroundColor());
  }

  if (suggestion.description != null) {
    presentation
        .appendTailText(" (" + getFirstSentenceWithoutDot(suggestion.description) + ")",
            true);
  }

  if (suggestion.shortType != null) {
    presentation.setTypeText(suggestion.shortType);
  }
}
 
Example 12
Source File: BuildLookupElement.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void renderElement(LookupElementPresentation presentation) {
  presentation.setItemText(getItemText());
  presentation.setTailText(getTailText());
  presentation.setTypeText(getTypeText());
  presentation.setIcon(getIcon());
}
 
Example 13
Source File: RouteLookupElement.java    From idea-php-typo3-plugin with MIT License 5 votes vote down vote up
@Override
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(getLookupString());
    presentation.setIcon(TYPO3CMSIcons.ROUTE_ICON);
    presentation.setTypeText(route.getController());
    presentation.setTypeGrayed(true);
}
 
Example 14
Source File: ExistFileLookupElement.java    From yiistorm with MIT License 5 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(title);
    ImageIcon icon = new ImageIcon(this.getClass().getResource("/com/yiistorm/images/yii.png"));
    presentation.setIcon(icon);
    presentation.setTypeText(createTitle);
    presentation.setTypeGrayed(false);
}
 
Example 15
Source File: PhpClassAnnotationLookupElement.java    From idea-php-annotation-plugin with MIT License 4 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(getLookupString());
    presentation.setTypeText(tailText != null ? tailText : this.phpClass.getPresentableFQN());
    presentation.setIcon(this.phpClass.getIcon());
    presentation.setStrikeout(this.phpClass.isDeprecated());
}
 
Example 16
Source File: ServiceLookupElement.java    From silex-idea-plugin with MIT License 4 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {

        presentation.setItemText(getLookupString());
        presentation.setTypeText(service.getClassName().substring(1));
        presentation.setIcon(Icons.Service);
    }
 
Example 17
Source File: ControllerActionLookupElement.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(getLookupString());
    presentation.setTypeText(StringUtils.stripStart(controllerAction.getMethod().getFQN(), "\\"));
    presentation.setTypeGrayed(true);
    presentation.setIcon(PhpIcons.METHOD_ICON);
}
 
Example 18
Source File: ConfigComponentLookupElement.java    From yiistorm with MIT License 4 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(title);
    presentation.setIcon(icon);
    presentation.setTypeText("application component");
    presentation.setTypeGrayed(false);
}
 
Example 19
Source File: TemplateLookupElement.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(getLookupString());
    presentation.setIcon(this.virtualFile.getFileType().getIcon());
    presentation.setTypeText(VfsUtil.getRelativePath(this.virtualFile, this.projectBaseDir, '/'));
    presentation.setTypeGrayed(true);
}
 
Example 20
Source File: ParameterLookupElement.java    From silex-idea-plugin with MIT License 3 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {

        presentation.setItemText(getLookupString());
        presentation.setTypeText(parameter.getType().toString());

        if (!parameter.getValue().isEmpty())
            presentation.appendTailText("(" + parameter.getValue() + ")", true);

        presentation.setIcon(Icons.Parameter);
    }