Search in sources :

Example 1 with OutputPathType

use of org.jetbrains.osgi.jps.model.OutputPathType in project intellij-plugins by JetBrains.

the class OsmorcFacetType method completeDefaultConfiguration.

private static void completeDefaultConfiguration(OsmorcFacetConfiguration configuration, Module module) {
    if (StringUtil.isEmpty(configuration.getJarFileLocation())) {
        String jarFileName = module.getName().replaceAll("[\\s]", "_") + ".jar";
        // by default put stuff into the compiler output path.
        OutputPathType outputPathType = OutputPathType.CompilerOutputPath;
        ProjectSettings projectSettings = ProjectSettings.getInstance(module.getProject());
        if (projectSettings != null) {
            String bundlesOutputPath = projectSettings.getBundlesOutputPath();
            if (StringUtil.isNotEmpty(bundlesOutputPath)) {
                outputPathType = OutputPathType.OsgiOutputPath;
            }
        }
        configuration.setJarFileLocation(jarFileName, outputPathType);
    }
}
Also used : OutputPathType(org.jetbrains.osgi.jps.model.OutputPathType) ProjectSettings(org.osmorc.settings.ProjectSettings)

Example 2 with OutputPathType

use of org.jetbrains.osgi.jps.model.OutputPathType 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;
}
Also used : OsmorcFacetConfiguration(org.osmorc.facet.OsmorcFacetConfiguration) OutputPathType(org.jetbrains.osgi.jps.model.OutputPathType)

Example 3 with OutputPathType

use of org.jetbrains.osgi.jps.model.OutputPathType in project intellij-plugins by JetBrains.

the class OsmorcFacetJAREditorTab method apply.

@Override
public void apply() throws ConfigurationException {
    String jarFileName = myJarFileTextField.getText();
    if (StringUtil.isEmptyOrSpaces(jarFileName)) {
        throw new ConfigurationException(OsmorcBundle.message("facet.editor.jar.empty.jar.name"));
    }
    OsmorcFacetConfiguration configuration = (OsmorcFacetConfiguration) myEditorContext.getFacet().getConfiguration();
    OutputPathType pathType = getSelectedOutputPathType();
    if (pathType == SpecificOutputPath) {
        String location = myJarOutputPathChooser.getText();
        if (StringUtil.isEmptyOrSpaces(location)) {
            throw new ConfigurationException(OsmorcBundle.message("facet.editor.jar.empty.output.path"));
        }
        String completeOutputPath = new File(location, jarFileName).getPath();
        configuration.setJarFileLocation(completeOutputPath, pathType);
    } else {
        configuration.setJarFileLocation(jarFileName, pathType);
    }
    configuration.setIgnoreFilePattern(myIgnoreFilePatternTextField.getText());
    configuration.setAlwaysRebuildBundleJAR(myAlwaysRebuildBundleJARCheckBox.isSelected());
    configuration.setAdditionalJARContents(myAdditionalJARContentsTableModel.getAdditionalContents());
    myModified = false;
}
Also used : OsmorcFacetConfiguration(org.osmorc.facet.OsmorcFacetConfiguration) OutputPathType(org.jetbrains.osgi.jps.model.OutputPathType) ConfigurationException(com.intellij.openapi.options.ConfigurationException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) File(java.io.File)

Example 4 with OutputPathType

use of org.jetbrains.osgi.jps.model.OutputPathType in project intellij-plugins by JetBrains.

the class OsmorcFacetConfiguration method readExternal.

@Override
public void readExternal(Element element) {
    if (element.getAttributeValue(MANIFEST_GENERATION_MODE) == null) {
        // the new attribute is not there, so we got an old file, to be converted.
        // legacy files containing boolean values
        boolean osmorcControlsManifest = Boolean.parseBoolean(element.getAttributeValue(OSMORC_CONTROLS_MANIFEST, "true"));
        boolean useBndFile = Boolean.parseBoolean(element.getAttributeValue(USE_BND_FILE, "false"));
        boolean useBundlorFile = Boolean.parseBoolean(element.getAttributeValue(USE_BUNDLOR_FILE, "false"));
        // default is that osmorc controls the manifest, so set this in case the config file has been manually edited or is otherwise invalid
        setManifestGenerationMode(ManifestGenerationMode.OsmorcControlled);
        if (osmorcControlsManifest && !useBndFile && !useBundlorFile) {
            setManifestGenerationMode(ManifestGenerationMode.OsmorcControlled);
        } else if ((!osmorcControlsManifest && useBndFile && !useBundlorFile) || (/* workaround */
        osmorcControlsManifest && useBndFile && !useBundlorFile)) {
            setManifestGenerationMode(ManifestGenerationMode.Bnd);
        } else if (!osmorcControlsManifest && !useBndFile && useBundlorFile) {
            setManifestGenerationMode(ManifestGenerationMode.Bundlor);
        } else if (!osmorcControlsManifest && !useBndFile) {
            setManifestGenerationMode(ManifestGenerationMode.Manually);
        } else {
            String message = "The configuration at least one OSGi facet is invalid and has been reset. Please check your facet settings!";
            OsmorcProjectComponent.IMPORTANT_NOTIFICATIONS.createNotification(message, NotificationType.WARNING).notify(myFacet.getModule().getProject());
        }
    } else {
        // attribute it there, read it.
        String manifestGenerationModeName = element.getAttributeValue(MANIFEST_GENERATION_MODE, ManifestGenerationMode.OsmorcControlled.name());
        ManifestGenerationMode manifestGenerationMode = ManifestGenerationMode.valueOf(manifestGenerationModeName);
        setManifestGenerationMode(manifestGenerationMode);
    }
    setBndFileLocation(element.getAttributeValue(BND_FILE_LOCATION));
    setBundlorFileLocation(element.getAttributeValue(BUNDLOR_FILE_LOCATION));
    setManifestLocation(element.getAttributeValue(MANIFEST_LOCATION));
    String outputPathTypeName = element.getAttributeValue(OUTPUT_PATH_TYPE, OutputPathType.SpecificOutputPath.name());
    OutputPathType outputPathType = OutputPathType.valueOf(outputPathTypeName);
    setJarFileLocation(element.getAttributeValue(JAR_FILE_LOCATION), outputPathType);
    setBundleActivator(element.getAttributeValue(BUNDLE_ACTIVATOR));
    setBundleSymbolicName(element.getAttributeValue(BUNDLE_SYMBOLIC_NAME));
    setBundleVersion(element.getAttributeValue(BUNDLE_VERSION));
    setIgnoreFilePattern(element.getAttributeValue(IGNORE_FILE_PATTERN));
    setUseProjectDefaultManifestFileLocation(Boolean.parseBoolean(element.getAttributeValue(USE_PROJECT_DEFAULT_MANIFEST_FILE_LOCATION, "true")));
    setAlwaysRebuildBundleJAR(Boolean.parseBoolean(element.getAttributeValue(ALWAYS_REBUILD_BUNDLE_JAR, "false")));
    setDoNotSynchronizeWithMaven(Boolean.parseBoolean(element.getAttributeValue(DO_NOT_SYNCHRONIZE_WITH_MAVEN, "false")));
    Element props = element.getChild(ADDITIONAL_PROPERTIES);
    if (props != null) {
        List children = props.getChildren();
        if (children.isEmpty()) {
            // ok this is a legacy file
            setAdditionalProperties(props.getText());
        } else {
            StringBuilder builder = new StringBuilder();
            // new handling as fix for OSMORC-43
            for (Object child : children) {
                Element prop = (Element) child;
                builder.append(prop.getAttributeValue(KEY)).append(":").append(prop.getAttributeValue(VALUE)).append("\n");
            }
            setAdditionalProperties(builder.toString());
        }
    }
    List<Pair<String, String>> additionalJARContents = getAdditionalJARContents();
    Element additionalJARContentsElement = element.getChild("additionalJARContents");
    if (additionalJARContentsElement != null) {
        @SuppressWarnings({ "unchecked" }) List<Element> children = additionalJARContentsElement.getChildren("entry");
        for (Element entryElement : children) {
            additionalJARContents.add(Pair.create(entryElement.getAttributeValue("source"), entryElement.getAttributeValue("dest")));
        }
    }
    myModificationCount++;
}
Also used : ManifestGenerationMode(org.jetbrains.osgi.jps.model.ManifestGenerationMode) OutputPathType(org.jetbrains.osgi.jps.model.OutputPathType) Element(org.jdom.Element) ArrayList(java.util.ArrayList) List(java.util.List) Pair(com.intellij.openapi.util.Pair)

Aggregations

OutputPathType (org.jetbrains.osgi.jps.model.OutputPathType)4 OsmorcFacetConfiguration (org.osmorc.facet.OsmorcFacetConfiguration)2 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 Pair (com.intellij.openapi.util.Pair)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Element (org.jdom.Element)1 ManifestGenerationMode (org.jetbrains.osgi.jps.model.ManifestGenerationMode)1 ProjectSettings (org.osmorc.settings.ProjectSettings)1