com.intellij.lang.properties.IProperty Java Examples
The following examples show how to use
com.intellij.lang.properties.IProperty.
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: DecryptPropertyAction.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@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); }
Example #2
Source File: EncryptPropertyAction.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@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); }
Example #3
Source File: PropertiesCompletionProvider.java From component-runtime with Apache License 2.0 | 5 votes |
@Override protected void addCompletions(final CompletionParameters completionParameters, final ProcessingContext processingContext, final CompletionResultSet resultSet) { final PsiElement element = completionParameters.getPosition(); if (!LeafPsiElement.class.isInstance(element)) { return; // ignore comment } final Project project = element.getProject(); final Module module = findModule(element); final SuggestionService service = ServiceManager.getService(project, SuggestionService.class); if ((module == null || !service.isSupported(completionParameters))) { // limit suggestion to Messages return; } if (PropertyValueImpl.class.isInstance(element)) { ofNullable(PropertyValueImpl.class.cast(element).getPrevSibling()) .map(PsiElement::getPrevSibling) .map(PsiElement::getText) .ifPresent(text -> resultSet.addAllElements(service.computeValueSuggestions(text))); } else if (PropertyKeyImpl.class.isInstance(element)) { final List<String> containerElements = PropertiesFileImpl.class .cast(element.getContainingFile()) .getProperties() .stream() .filter(p -> !Objects.equals(p.getKey(), element.getText())) .map(IProperty::getKey) .collect(toList()); resultSet .addAllElements(service .computeKeySuggestions(project, module, getPropertiesPackage(module, completionParameters), containerElements, truncateIdeaDummyIdentifier(element))); } }
Example #4
Source File: NutzInjectConfUtil.java From NutzCodeInsight with Apache License 2.0 | 5 votes |
public static List<PsiElement> findPropertiesPsiElement(Project project, Collection<VirtualFile> virtualFiles, String key) { List<PsiElement> result = new ArrayList<>(); for (VirtualFile virtualFile : virtualFiles) { PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile); List<IProperty> iProperties = ((PropertiesFileImpl) psiFile).getProperties(); iProperties.forEach(iProperty -> { if (iProperty.getKey().equals(key)) { result.add(iProperty.getPsiElement()); } }); } return result; }
Example #5
Source File: DecryptPropertyAction.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent anActionEvent) { final Project project = (Project) anActionEvent.getData(CommonDataKeys.PROJECT); PsiFile psiFile = anActionEvent.getData(CommonDataKeys.PSI_FILE); IProperty selectedProperty = getSelectedProperty(anActionEvent.getDataContext()); final EncryptDialog form = new EncryptDialog(); form.setTitle("Decrypt Property: " + selectedProperty.getKey()); form.show(); boolean isOk = form.getExitCode() == DialogWrapper.OK_EXIT_CODE; logger.debug("**** ALGORITHM " + form.getAlgorithm().getSelectedItem()); logger.debug("**** MODE " + form.getMode().getSelectedItem()); if (isOk) { new WriteCommandAction.Simple(project, psiFile) { @Override protected void run() throws Throwable { EncryptionAlgorithm algorithm = (EncryptionAlgorithm) form.getAlgorithm().getSelectedItem(); EncryptionMode mode = (EncryptionMode) form.getMode().getSelectedItem(); try { String originalValue = selectedProperty.getValue(); String encryptedProperty = originalValue.substring(2, originalValue.length() - 1); byte[] decryptedBytes = algorithm.getBuilder().forKey(form.getEncryptionKey().getText()).using(mode) .build().decrypt(Base64.decode(encryptedProperty)); selectedProperty.setValue(new String(decryptedBytes)); } catch (Exception e) { Notification notification = MuleUIUtils.MULE_NOTIFICATION_GROUP.createNotification("Unable to decrypt property", "Property '" + selectedProperty.getKey() + "' cannot be decrypted : " + e, NotificationType.ERROR, null); Notifications.Bus.notify(notification, project); } } }.execute(); } }
Example #6
Source File: EncryptPropertyAction.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent anActionEvent) { final Project project = (Project)anActionEvent.getData(CommonDataKeys.PROJECT); PsiFile psiFile = anActionEvent.getData(CommonDataKeys.PSI_FILE); IProperty selectedProperty = getSelectedProperty(anActionEvent.getDataContext()); if (selectedProperty == null) return; final EncryptDialog form = new EncryptDialog(); form.setTitle("Encrypt Property: " + selectedProperty.getKey()); form.show(); boolean isOk = form.getExitCode() == DialogWrapper.OK_EXIT_CODE; // System.out.println("******** IS OK " + isOk); logger.debug("**** ALGORITHM " + form.getAlgorithm().getSelectedItem()); logger.debug("**** MODE " + form.getMode().getSelectedItem()); if (isOk) { new WriteCommandAction.Simple(project, psiFile) { @Override protected void run() throws Throwable { EncryptionAlgorithm algorithm = (EncryptionAlgorithm) form.getAlgorithm().getSelectedItem(); EncryptionMode mode = (EncryptionMode) form.getMode().getSelectedItem(); byte[] encryptedBytes = algorithm.getBuilder().forKey(form.getEncryptionKey().getText()).using(mode) .build().encrypt(selectedProperty.getValue().getBytes()); StringBuilder result = new StringBuilder(); result.append(ENCRYPT_PREFIX); result.append(new String(Base64.encode(encryptedBytes))); result.append(ENCRYPT_SUFFIX); selectedProperty.setValue(result.toString()); } }.execute(); } }