use of org.osmorc.facet.OsmorcFacetConfiguration in project intellij-plugins by JetBrains.
the class OsmorcFacetGeneralEditorTab method apply.
@Override
public void apply() throws ConfigurationException {
OsmorcFacetConfiguration configuration = (OsmorcFacetConfiguration) myEditorContext.getFacet().getConfiguration();
configuration.setManifestGenerationMode(myControlledByOsmorcRadioButton.isSelected() ? ManifestGenerationMode.OsmorcControlled : myUseBndFileRadioButton.isSelected() ? ManifestGenerationMode.Bnd : myUseBundlorFileRadioButton.isSelected() ? ManifestGenerationMode.Bundlor : ManifestGenerationMode.Manually);
configuration.setManifestLocation(FileUtil.toSystemIndependentName(myManifestFileChooser.getText()));
configuration.setUseProjectDefaultManifestFileLocation(myUseProjectDefaultManifestFileLocation.isSelected());
configuration.setBndFileLocation(FileUtil.toSystemIndependentName(myBndFile.getText()));
configuration.setBundlorFileLocation(FileUtil.toSystemIndependentName(myBundlorFile.getText()));
configuration.setDoNotSynchronizeWithMaven(myDoNotSynchronizeFacetCheckBox.isSelected());
myModified = false;
}
use of org.osmorc.facet.OsmorcFacetConfiguration in project intellij-plugins by JetBrains.
the class OsmorcFacetImporter method reimportFacet.
@Override
protected void reimportFacet(IdeModifiableModelsProvider modelsProvider, Module module, MavenRootModelAdapter mavenRootModelAdapter, OsmorcFacet osmorcFacet, MavenProjectsTree mavenProjectsTree, MavenProject mavenProject, MavenProjectChanges changes, Map<MavenProject, String> mavenProjectStringMap, List<MavenProjectsProcessorTask> mavenProjectsProcessorPostConfigurationTasks) {
OsmorcFacetConfiguration conf = osmorcFacet.getConfiguration();
if (conf.isDoNotSynchronizeWithMaven()) {
return;
}
// first off, we get the defaults
MavenId id = mavenProject.getMavenId();
conf.setBundleSymbolicName(id.getGroupId() + "." + id.getArtifactId());
conf.setBundleVersion(ImporterUtil.cleanupVersion(id.getVersion()));
MavenPlugin plugin = mavenProject.findPlugin(myPluginGroupID, myPluginArtifactID);
if (plugin == null) {
return;
}
// Check if there are any overrides set up in the maven plugin settings
// IDEA-63243
conf.setBundleSymbolicName(computeSymbolicName(mavenProject));
// to preserve the order of elements
Map<String, String> props = ContainerUtil.newLinkedHashMap();
Map<String, String> modelMap = mavenProject.getModelMap();
String description = modelMap.get("description");
if (!StringUtil.isEmptyOrSpaces(description)) {
props.put(Constants.BUNDLE_DESCRIPTION, description);
}
String licenses = modelMap.get("licenses");
if (!StringUtil.isEmptyOrSpaces(licenses)) {
props.put("Bundle-License", licenses);
}
String vendor = modelMap.get("organization.name");
if (!StringUtil.isEmpty(vendor)) {
props.put(Constants.BUNDLE_VENDOR, vendor);
}
String docUrl = modelMap.get("organization.url");
if (!StringUtil.isEmptyOrSpaces(docUrl)) {
props.put(Constants.BUNDLE_DOCURL, docUrl);
}
// load versions if any
Map<String, String> versions = cleanVersions(plugin);
// now find any additional properties that might have been set up:
Element instructionsNode = getConfig(mavenProject, "instructions");
if (instructionsNode != null) {
boolean useExistingManifest = false;
for (Element child : instructionsNode.getChildren()) {
String name = child.getName();
String value = child.getTextTrim();
value = value.replaceAll("\\p{Blank}*[\r\n]\\p{Blank}*", "");
value = substituteVersions(value, versions);
if (INCLUDE_MANIFEST.equals(name)) {
conf.setManifestLocation(value);
conf.setManifestGenerationMode(ManifestGenerationMode.Manually);
conf.setUseProjectDefaultManifestFileLocation(false);
useExistingManifest = true;
} else if (Constants.BUNDLE_VERSION.equals(name)) {
conf.setBundleVersion(value);
} else if (Constants.BUNDLE_ACTIVATOR.equals(name)) {
conf.setBundleActivator(value);
} else if (!StringUtil.isEmpty(value) && !Constants.BUNDLE_SYMBOLICNAME.equals(name)) {
if (StringUtil.startsWithChar(name, '_')) {
// sanitize instructions
name = "-" + name.substring(1);
}
props.put(name, value);
}
}
if (!useExistingManifest) {
conf.setManifestLocation("");
conf.setManifestGenerationMode(ManifestGenerationMode.OsmorcControlled);
conf.setUseProjectDefaultManifestFileLocation(true);
}
}
// check if bundle name exists, if not compute it (IDEA-63244)
if (!props.containsKey(Constants.BUNDLE_NAME)) {
props.put(Constants.BUNDLE_NAME, computeBundleName(mavenProject));
}
// now post-process the settings, to make Embed-Dependency work
ImporterUtil.postProcessAdditionalProperties(props, mavenProject, module.getProject());
// Fix for IDEA-63242 - don't merge it with the existing settings, overwrite them
conf.importAdditionalProperties(props, true);
// Fix for IDEA-66235 - inherit jar filename from maven
String jarFileName = mavenProject.getFinalName() + ".jar";
// FiX for IDEA-67088, preserve existing output path settings on reimport.
switch(conf.getOutputPathType()) {
case OsgiOutputPath:
conf.setJarFileLocation(jarFileName, OutputPathType.OsgiOutputPath);
break;
case SpecificOutputPath:
String path = new File(conf.getJarFilePath(), jarFileName).getPath();
conf.setJarFileLocation(path, OutputPathType.SpecificOutputPath);
break;
default:
conf.setJarFileLocation(jarFileName, OutputPathType.CompilerOutputPath);
}
}
use of org.osmorc.facet.OsmorcFacetConfiguration in project intellij-plugins by JetBrains.
the class UnregisteredActivatorInspection method buildVisitor.
@NotNull
@Override
protected PsiElementVisitor buildVisitor(final OsmorcFacet facet, final ProblemsHolder holder, boolean isOnTheFly) {
if (!(holder.getFile() instanceof PsiClassOwner))
return PsiElementVisitor.EMPTY_VISITOR;
return new JavaElementVisitor() {
@Override
public void visitFile(PsiFile file) {
if (file instanceof PsiClassOwner) {
for (PsiClass psiClass : ((PsiClassOwner) file).getClasses()) {
String className = psiClass.getQualifiedName();
if (OsgiPsiUtil.isActivator(psiClass) && className != null) {
BundleManifest manifest = BundleManifestCache.getInstance(psiClass.getProject()).getManifest(facet.getModule());
if (manifest != null && !className.equals(manifest.getBundleActivator())) {
LocalQuickFix[] fixes = LocalQuickFix.EMPTY_ARRAY;
OsmorcFacetConfiguration configuration = facet.getConfiguration();
if (configuration.isManifestManuallyEdited()) {
fixes = new LocalQuickFix[] { new RegisterInManifestQuickfix(className) };
} else if (configuration.isOsmorcControlsManifest()) {
fixes = new LocalQuickFix[] { new RegisterInConfigurationQuickfix(className, configuration) };
}
PsiElement identifier = unwrap(psiClass.getNameIdentifier());
if (identifier != null) {
holder.registerProblem(identifier, OsmorcBundle.message("UnregisteredActivatorInspection.message"), fixes);
}
}
}
}
}
}
};
}
use of org.osmorc.facet.OsmorcFacetConfiguration in project intellij-plugins by JetBrains.
the class AbstractOsgiQuickFix method getVerifiedManifestFile.
@Nullable
protected ManifestFile getVerifiedManifestFile(@NotNull PsiElement element) {
Module module = ModuleUtilCore.findModuleForPsiElement(element);
assert module != null : element;
OsmorcFacet facet = OsmorcFacet.getInstance(module);
if (facet != null) {
OsmorcFacetConfiguration configuration = facet.getConfiguration();
for (VirtualFile root : ModuleRootManager.getInstance(module).getContentRoots()) {
VirtualFile file = root.findFileByRelativePath(configuration.getManifestLocation());
if (file != null) {
PsiFile psiFile = element.getManager().findFile(file);
if (psiFile instanceof ManifestFile && CommonRefactoringUtil.checkReadOnlyStatus(psiFile)) {
return (ManifestFile) psiFile;
}
}
}
}
OsmorcBundle.notification(getFamilyName(), OsmorcBundle.message("inspection.fix.no.manifest"), NotificationType.WARNING).notify(element.getProject());
return null;
}
use of org.osmorc.facet.OsmorcFacetConfiguration in project intellij-plugins by JetBrains.
the class OsmorcFacetJAREditorTab method reset.
@Override
public void reset() {
OsmorcFacetConfiguration configuration = (OsmorcFacetConfiguration) myEditorContext.getFacet().getConfiguration();
OutputPathType outputPathType = configuration.getOutputPathType();
myPlaceInCompilerOutputPathRadioButton.setSelected(outputPathType == CompilerOutputPath);
myPlaceInProjectWideRadioButton.setSelected(outputPathType == OsgiOutputPath);
myPlaceInThisPathRadioButton.setSelected(outputPathType == SpecificOutputPath);
myJarFileTextField.setText(configuration.getJarFileName());
if (outputPathType == SpecificOutputPath) {
myJarOutputPathChooser.setText(configuration.getJarFilePath());
} else {
myJarOutputPathChooser.setText("");
}
myAdditionalJARContentsTableModel.replaceContent(configuration.getAdditionalJARContents());
myIgnoreFilePatternTextField.setText(configuration.getIgnoreFilePattern());
myAlwaysRebuildBundleJARCheckBox.setSelected(configuration.isAlwaysRebuildBundleJAR());
updateGui();
myModified = false;
}
Aggregations