本文整理汇总了Java中com.intellij.lang.properties.IProperty.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java IProperty.getValue方法的具体用法?Java IProperty.getValue怎么用?Java IProperty.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.lang.properties.IProperty
的用法示例。
在下文中一共展示了IProperty.getValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import com.intellij.lang.properties.IProperty; //导入方法依赖的package包/类
@Override
public void update(AnActionEvent anActionEvent) {
final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(anActionEvent.getDataContext());
boolean isProperty = false;
boolean isPropertyFile = false;
boolean isEncrypted = false;
if (file != null) {
isPropertyFile = "properties".equalsIgnoreCase(file.getExtension());
if (isPropertyFile) {
IProperty selectedProperty = getSelectedProperty(anActionEvent.getDataContext());
if (selectedProperty != null) {
String propertyValue = selectedProperty.getValue();
isEncrypted = (propertyValue.startsWith("![") && propertyValue.endsWith("]"));
isProperty = true;
}
}
}
anActionEvent.getPresentation().setEnabled(isPropertyFile && isEncrypted && isProperty);
anActionEvent.getPresentation().setVisible(isPropertyFile && isProperty);
}
示例2: update
import com.intellij.lang.properties.IProperty; //导入方法依赖的package包/类
@Override
public void update(AnActionEvent anActionEvent)
{
final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(anActionEvent.getDataContext());
boolean isProperty = false;
boolean isPropertyFile = false;
boolean isEncrypted = false;
if (file != null)
{
isPropertyFile = "properties".equalsIgnoreCase(file.getExtension());
if (isPropertyFile) {
IProperty selectedProperty = getSelectedProperty(anActionEvent.getDataContext());
if (selectedProperty != null) {
String propertyValue = selectedProperty.getValue();
isEncrypted = (propertyValue.startsWith("![") && propertyValue.endsWith("]"));
isProperty = true;
}
}
}
anActionEvent.getPresentation().setEnabled(isPropertyFile && !isEncrypted && isProperty);
anActionEvent.getPresentation().setVisible(isPropertyFile && isProperty);
}
示例3: getPlaceholderText
import com.intellij.lang.properties.IProperty; //导入方法依赖的package包/类
@Override
public String getPlaceholderText(@NotNull ASTNode node) {
final PsiElement element = node.getPsi();
if (element instanceof XmlAttributeValue) {
IProperty property = getResolvedProperty((XmlAttributeValue) element);
return property == null ? element.getText() : "{" + property.getValue() + "}";
}
return element.getText();
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:10,代码来源:JspPropertyFoldingBuilder.java
示例4: fillPropertyList
import com.intellij.lang.properties.IProperty; //导入方法依赖的package包/类
private void fillPropertyList() {
myPairs = new ArrayList<Couple<String>>();
final List<IProperty> properties = myBundle.getProperties();
for (IProperty property : properties) {
final String key = property.getUnescapedKey();
final String value = property.getValue();
if (key != null) {
myPairs.add(Couple.of(key, value != null ? value : NULL));
}
}
Collections.sort(myPairs, new MyPairComparator());
}
示例5: renderElement
import com.intellij.lang.properties.IProperty; //导入方法依赖的package包/类
@Override
public void renderElement(LookupElement element, LookupElementPresentation presentation) {
IProperty property = (IProperty)element.getObject();
presentation.setIcon(PlatformIcons.PROPERTY_ICON);
String key = StringUtil.notNullize(property.getUnescapedKey());
presentation.setItemText(key);
PropertiesFile propertiesFile = property.getPropertiesFile();
ResourceBundle resourceBundle = propertiesFile.getResourceBundle();
String value = property.getValue();
boolean hasBundle = resourceBundle != EmptyResourceBundle.getInstance();
if (hasBundle) {
PropertiesFile defaultPropertiesFile = resourceBundle.getDefaultPropertiesFile();
IProperty defaultProperty = defaultPropertiesFile.findPropertyByKey(key);
if (defaultProperty != null) {
value = defaultProperty.getValue();
}
}
if (hasBundle) {
presentation.setTypeText(resourceBundle.getBaseName(), AllIcons.FileTypes.Properties);
}
if (presentation instanceof RealLookupElementPresentation && value != null) {
value = "=" + value;
int limit = 1000;
if (value.length() > limit || !((RealLookupElementPresentation)presentation).hasEnoughSpaceFor(value, false)) {
if (value.length() > limit) {
value = value.substring(0, limit);
}
while (value.length() > 0 && !((RealLookupElementPresentation)presentation).hasEnoughSpaceFor(value + "...", false)) {
value = value.substring(0, value.length() - 1);
}
value += "...";
}
}
TextAttributes attrs = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(PropertiesHighlighter.PROPERTY_VALUE);
presentation.setTailText(value, attrs.getForegroundColor());
}
示例6: getPropertyEditorValue
import com.intellij.lang.properties.IProperty; //导入方法依赖的package包/类
@NotNull
public static String getPropertyEditorValue(@Nullable final IProperty property) {
if (property == null) {
return "";
}
else {
String rawValue = property.getValue();
return rawValue == null ? "" : PropertiesResourceBundleUtil.fromPropertyValueToValueEditor(rawValue);
}
}
示例7: sortPropertiesFile
import com.intellij.lang.properties.IProperty; //导入方法依赖的package包/类
private static void sortPropertiesFile(final PropertiesFile file) {
final List<IProperty> properties = new ArrayList<IProperty>(file.getProperties());
Collections.sort(properties, new Comparator<IProperty>() {
@Override
public int compare(@NotNull IProperty p1, @NotNull IProperty p2) {
return Comparing.compare(p1.getKey(), p2.getKey(), String.CASE_INSENSITIVE_ORDER);
}
});
final char delimiter = PropertiesCodeStyleSettings.getInstance(file.getProject()).KEY_VALUE_DELIMITER;
final StringBuilder rawText = new StringBuilder();
for (int i = 0; i < properties.size(); i++) {
IProperty property = properties.get(i);
final String value = property.getValue();
final String commentAboveProperty = property.getDocCommentText();
if (commentAboveProperty != null) {
rawText.append(commentAboveProperty).append("\n");
}
final String propertyText =
PropertiesElementFactory.getPropertyText(property.getKey(), value != null ? value : "", delimiter, null, false);
rawText.append(propertyText);
if (i != properties.size() - 1) {
rawText.append("\n");
}
}
final PropertiesFile fakeFile = PropertiesElementFactory.createPropertiesFile(file.getProject(), rawText.toString());
final PropertiesList propertiesList = PsiTreeUtil.findChildOfType(file.getContainingFile(), PropertiesList.class);
LOG.assertTrue(propertiesList != null);
final PropertiesList fakePropertiesList = PsiTreeUtil.findChildOfType(fakeFile.getContainingFile(), PropertiesList.class);
LOG.assertTrue(fakePropertiesList != null);
propertiesList.replace(fakePropertiesList);
}
示例8: getApplicationName
import com.intellij.lang.properties.IProperty; //导入方法依赖的package包/类
@Override
public String getApplicationName(Module module) {
final VirtualFile appProperties = getApplicationPropertiesFile(module);
if (appProperties != null) {
final PsiFile file = PsiManager.getInstance(module.getProject()).findFile(appProperties);
if (file instanceof PropertiesFile) {
final IProperty property = ((PropertiesFile)file).findPropertyByKey("application.name");
return property != null ? property.getValue() : super.getApplicationName(module);
}
}
return super.getApplicationName(module);
}
示例9: formatI18nProperty
import com.intellij.lang.properties.IProperty; //导入方法依赖的package包/类
private static String formatI18nProperty(PsiLiteralExpression literal, IProperty property) {
return property == null ?
literal.getText() : "\"" + property.getValue() + "\"";
}
示例10: inlineElement
import com.intellij.lang.properties.IProperty; //导入方法依赖的package包/类
public void inlineElement(final Project project, Editor editor, PsiElement psiElement) {
if (!(psiElement instanceof IProperty)) return;
IProperty property = (IProperty)psiElement;
final String propertyValue = property.getValue();
if (propertyValue == null) return;
final List<PsiElement> occurrences = Collections.synchronizedList(ContainerUtil.<PsiElement>newArrayList());
final Collection<PsiFile> containingFiles = Collections.synchronizedSet(new HashSet<PsiFile>());
containingFiles.add(psiElement.getContainingFile());
boolean result = ReferencesSearch.search(psiElement).forEach(
new Processor<PsiReference>() {
public boolean process(final PsiReference psiReference) {
PsiElement element = psiReference.getElement();
PsiElement parent = element.getParent();
if (parent instanceof PsiExpressionList && parent.getParent() instanceof PsiMethodCallExpression) {
if (((PsiExpressionList)parent).getExpressions().length == 1) {
occurrences.add(parent.getParent());
containingFiles.add(element.getContainingFile());
return true;
}
}
return false;
}
}
);
if (!result) {
CommonRefactoringUtil.showErrorHint(project, editor, "Property has non-method usages", REFACTORING_NAME, null);
}
if (occurrences.isEmpty()) {
CommonRefactoringUtil.showErrorHint(project, editor, "Property has no usages", REFACTORING_NAME, null);
return;
}
if (!ApplicationManager.getApplication().isUnitTestMode()) {
String occurrencesString = RefactoringBundle.message("occurrences.string", occurrences.size());
String question =
PropertiesBundle.message("inline.property.confirmation", property.getName(), propertyValue) + " " + occurrencesString;
RefactoringMessageDialog dialog = new RefactoringMessageDialog(REFACTORING_NAME, question, HelpID.INLINE_VARIABLE,
"OptionPane.questionIcon", true, project);
if (!dialog.showAndGet()) {
return;
}
}
final RefactoringEventData data = new RefactoringEventData();
data.addElement(psiElement.copy());
new WriteCommandAction.Simple(project, REFACTORING_NAME, containingFiles.toArray(new PsiFile[containingFiles.size()])) {
@Override
protected void run() throws Throwable {
project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringStarted(REFACTORING_ID, data);
PsiLiteral stringLiteral = (PsiLiteral)JavaPsiFacade.getInstance(getProject()).getElementFactory().
createExpressionFromText("\"" + StringUtil.escapeStringCharacters(propertyValue) + "\"", null);
for (PsiElement occurrence : occurrences) {
occurrence.replace(stringLiteral.copy());
}
project.getMessageBus().syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC).refactoringDone(REFACTORING_ID, null);
}
}.execute();
}