Search in sources :

Example 1 with ProductIdentity

use of org.eclipse.titan.common.product.ProductIdentity in project titan.EclipsePlug-ins by eclipse.

the class TITANPreferencePage method refreshTITANInfo.

/**
 * Refreshes the information displayed on this page related to the
 * version of TITAN used currently.
 */
private void refreshTITANInfo() {
    if (titanVersionInformation == null) {
        return;
    }
    String tempPath = installPath.getStringValue();
    if (tempPath == null || tempPath.length() == 0) {
        return;
    }
    String temp = installPath.getStringValue() + CompilerVersionInformationCollector.COMPILER_SUBPATH;
    if (Platform.OS_WIN32.equals(Platform.getOS())) {
        temp = temp + ".exe";
    }
    IPath compilerPath = new Path(temp);
    if (!compilerPath.toFile().exists()) {
        installPath.getTextControl(getFieldEditorParent()).setToolTipText(INSTALL_PATH_TOOLTIP + "\n The compiler was not found on the path `" + compilerPath.toOSString() + "'");
        titanVersionInformation.setText("The compiler was not found on the path `" + compilerPath.toOSString() + "'");
        setErrorMessage("The compiler was not found on the path `" + compilerPath.toOSString() + "'");
        return;
    }
    String tempCompilerProductNumber = CompilerVersionInformationCollector.checkTemporalLocation(installPath.getStringValue());
    if (tempCompilerProductNumber == null) {
        installPath.getTextControl(getFieldEditorParent()).setToolTipText(INSTALL_PATH_TOOLTIP + "\n The version of the used compiler could not be determined.");
        titanVersionInformation.setText("The version of the compiler used: could not be determined");
        setErrorMessage("The version of the compiler used: could not be determined");
        return;
    }
    ProductIdentity versionNumber = ProductIdentityHelper.getProductIdentity(tempCompilerProductNumber, null);
    if (versionNumber == null) {
        installPath.getTextControl(getFieldEditorParent()).setToolTipText(INSTALL_PATH_TOOLTIP + "\n The version of the used compiler seems to be invalid/corrupted or there were problems while processing it.");
        titanVersionInformation.setText("The version of the compiler used: seems to be invalid/corrupted or there were problems while processing it");
        setErrorMessage("The version of the compiler used: seems to be invalid/corrupted or there were problems while processing it");
        return;
    }
    installPath.getTextControl(getFieldEditorParent()).setToolTipText(INSTALL_PATH_TOOLTIP + "\n The version of the used compiler is: " + versionNumber);
    titanVersionInformation.setText("The version of the compiler used: " + versionNumber);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) ProductIdentity(org.eclipse.titan.common.product.ProductIdentity)

Example 2 with ProductIdentity

use of org.eclipse.titan.common.product.ProductIdentity in project titan.EclipsePlug-ins by eclipse.

the class TITANPreferencePage method performOk.

@Override
public boolean performOk() {
    boolean result = super.performOk();
    IEclipsePreferences node = InstanceScope.INSTANCE.getNode(ProductConstants.PRODUCT_ID_DESIGNER);
    if (node != null) {
        try {
            node.flush();
        } catch (Exception e) {
            ErrorReporter.logExceptionStackTrace(e);
        }
    }
    CompilerVersionInformationCollector.clearStoredInformation();
    String temp = CompilerVersionInformationCollector.getCompilerProductNumber();
    ProductIdentity finalVersion = ProductIdentityHelper.getProductIdentity(temp, null);
    if (compilerProductNumber != null && compilerProductNumber.compareTo(finalVersion) != 0) {
        ErrorReporter.parallelWarningDisplayInMessageDialog("The compiler version has changed", "All projects are cleaned, so that files generated by the old compiler shall not corrupt further builds.\nThis might take some time.");
        compilerProductNumber = finalVersion;
        // remove all generated Makefiles if the TITAN version
        // has changed.
        IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
        for (IProject project : projects) {
            if (project.isAccessible() && TITANBuilder.isBuilderEnabled(project)) {
                TITANBuilder.cleanProjectForRebuild(project, false);
            }
        }
    }
    TITANInstallationValidator.clear();
    LicenseValidator.clear();
    return result;
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ProductIdentity(org.eclipse.titan.common.product.ProductIdentity) IProject(org.eclipse.core.resources.IProject)

Example 3 with ProductIdentity

use of org.eclipse.titan.common.product.ProductIdentity in project titan.EclipsePlug-ins by eclipse.

the class ProductIdentityHelper method getProductIdentity.

/**
 * Validates the input and if found correctly returns a version number
 * representing that version. Also if the location is set and the input
 * is erroneous, the error is reported to that location.
 *
 * @param versionString
 *                the version string in Ericsson format.
 * @param location
 *                if set the possible errors will be reported here.
 * @return the new version number, or null if the input is not correct.
 */
public static ProductIdentity getProductIdentity(final String versionString, final Location location) {
    if (versionString == null) {
        return null;
    }
    if ("RnXnn".equals(versionString)) {
        return new ProductIdentity();
    }
    String productNumber = null;
    String productNumberSuffix = null;
    String rNumber;
    if (PRODUCT_PATTERN1_MATCHER.reset(versionString).matches()) {
        productNumber = PRODUCT_PATTERN1_MATCHER.group(1);
        productNumberSuffix = PRODUCT_PATTERN1_MATCHER.group(2);
        rNumber = PRODUCT_PATTERN1_MATCHER.group(3);
    } else if (PRODUCT_PATTERN2_MATCHER.reset(versionString).matches()) {
        productNumber = PRODUCT_PATTERN2_MATCHER.group(1);
        rNumber = PRODUCT_PATTERN2_MATCHER.group(2);
    } else if (PRODUCT_PATTERN3_MATCHER.reset(versionString).matches()) {
        rNumber = PRODUCT_PATTERN3_MATCHER.group(1);
    } else {
        if (location != null) {
            location.reportSemanticError("Wrong format for product version information: The accepted formats resemble CRL 113 200/1 R9A");
        }
        return null;
    }
    String revisionDigit = null;
    String revisionLetter = null;
    String verificationStep = null;
    if (RNUMBER_PATTERN1_MATCHER.reset(rNumber).matches()) {
        revisionDigit = RNUMBER_PATTERN1_MATCHER.group(1);
        revisionLetter = RNUMBER_PATTERN1_MATCHER.group(2);
        verificationStep = RNUMBER_PATTERN1_MATCHER.group(3);
    } else if (RNUMBER_PATTERN2_MATCHER.reset(rNumber).matches()) {
        revisionDigit = RNUMBER_PATTERN2_MATCHER.group(1);
        revisionLetter = RNUMBER_PATTERN2_MATCHER.group(2);
    } else {
        if (location != null) {
            location.reportSemanticError("Wrong format for version information: The accepted formats resemble R2D02 and R2D");
        }
        return null;
    }
    int majorVersion = 0;
    if (productNumberSuffix != null) {
        try {
            final BigInteger temp = new BigInteger(productNumberSuffix);
            if (temp.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) >= 0) {
                if (location != null) {
                    location.reportSemanticError(MessageFormat.format("The major version number {0} is unexpectedly large, right now we can not handle such large numbers", temp));
                }
                return null;
            }
            majorVersion = temp.intValue();
        } catch (NumberFormatException e) {
            if (location != null) {
                location.reportSemanticError(MessageFormat.format("Wrong format for version information: the major version must be a number instead of {0}", productNumberSuffix));
            }
            return null;
        }
    }
    int minorVersion = 0;
    try {
        final BigInteger temp = new BigInteger(revisionDigit);
        if (temp.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) >= 0) {
            if (location != null) {
                location.reportSemanticError(MessageFormat.format("The minor version number {0} is unexpectedly large, right now we can not handle such large numbers", temp));
            }
            return null;
        }
        minorVersion = temp.intValue();
    } catch (NumberFormatException e) {
        if (location != null) {
            location.reportSemanticError(MessageFormat.format("Wrong format for version information: the minor version must be a number instead of {0}", revisionDigit));
        }
        return null;
    }
    final char c = revisionLetter.charAt(0);
    final int patchVersion = revisionLetter.codePointAt(0) - "A".codePointAt(0);
    switch(c) {
        case 'I':
        case 'O':
        case 'P':
        case 'Q':
        case 'R':
        case 'W':
            if (location != null) {
                location.reportSemanticError(MessageFormat.format("Letter {0} not allowed as patch version", c));
            }
            return null;
        default:
            break;
    }
    int buildVersion = 0;
    if (verificationStep != null) {
        try {
            final BigInteger temp = new BigInteger(verificationStep);
            if (temp.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) >= 0) {
                if (location != null) {
                    location.reportSemanticError(MessageFormat.format("The build version number {0} is unexpectedly large, right now we can not handle such large numbers", temp));
                }
                return null;
            }
            buildVersion = temp.intValue();
        } catch (NumberFormatException e) {
            if (location != null) {
                location.reportSemanticError(MessageFormat.format("Wrong format for version information: the build version must be a number instead of {0}", verificationStep));
            }
            return null;
        }
    }
    if ("CNL 113 300".equals(productNumber) && majorVersion == 0) {
        // in previous TITAN versions this information was not
        // stored.
        majorVersion = 1;
    }
    return ProductIdentity.getProductIdentity(productNumber, majorVersion, minorVersion, patchVersion, buildVersion);
}
Also used : ProductIdentity(org.eclipse.titan.common.product.ProductIdentity) BigInteger(java.math.BigInteger)

Example 4 with ProductIdentity

use of org.eclipse.titan.common.product.ProductIdentity in project titan.EclipsePlug-ins by eclipse.

the class LaunchConfigurationDelegate method launch.

@Override
public void launch(final ILaunchConfiguration arg0, final String arg1, final ILaunch arg2, final IProgressMonitor arg3) throws CoreException {
    final Exception exception = JNIMiddleWare.getException();
    if (null != exception) {
        final Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.OK, exception.getMessage(), exception);
        throw new CoreException(status);
    }
    final long version = JNIMiddleWare.getSharedLibraryVersion();
    final ProductIdentity currentVersion = ProductIdentity.getProductIdentity(ProductIdentity.TITAN_PRODUCT_NUMBER, version);
    if (versionLow.compareTo(currentVersion) > 0 || versionHigh.compareTo(currentVersion) < 0) {
        Status status;
        if (versionLow.equals(versionHigh)) {
            status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.OK, "Bad version of JNI dynamic library detected.\n" + "Supported version: " + versionHigh + "\n" + "Current version: " + currentVersion, null);
        } else {
            status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.OK, "Bad version of JNI dynamic library detected.\n" + "Supported versions: " + versionLow + " - " + versionHigh + "\n" + "Current version: " + currentVersion, null);
        }
        throw new CoreException(status);
    }
    if (JniExecutor.isRunning()) {
        Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.OK, "The Jni based launcher is already running.\n" + "Only one instance can be running at any time.", null);
        throw new CoreException(status);
    }
    showExecutionPerspective();
    final JniExecutor executor = new JniExecutor(arg0);
    executor.startSession(arg2);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) ProductIdentity(org.eclipse.titan.common.product.ProductIdentity) CoreException(org.eclipse.core.runtime.CoreException)

Example 5 with ProductIdentity

use of org.eclipse.titan.common.product.ProductIdentity in project titan.EclipsePlug-ins by eclipse.

the class TTCN3Module method analyzeExtensionAttributes.

/**
 * Convert and check the version, requires and titan version extension attributes.
 *
 * @param timestamp
 *                the timestamp of the actual build cycle.
 */
private void analyzeExtensionAttributes(final CompilationTimeStamp timestamp) {
    if (withAttributesPath == null) {
        return;
    }
    final List<SingleWithAttribute> realAttributes = withAttributesPath.getRealAttributes(timestamp);
    SingleWithAttribute attribute;
    List<AttributeSpecification> specifications = null;
    for (int i = 0; i < realAttributes.size(); i++) {
        attribute = realAttributes.get(i);
        if (Attribute_Type.Extension_Attribute.equals(attribute.getAttributeType())) {
            final Qualifiers qualifiers = attribute.getQualifiers();
            if (qualifiers == null || qualifiers.getNofQualifiers() == 0) {
                if (specifications == null) {
                    specifications = new ArrayList<AttributeSpecification>();
                }
                specifications.add(attribute.getAttributeSpecification());
            }
        }
    }
    if (specifications == null) {
        return;
    }
    final List<ExtensionAttribute> attributes = new ArrayList<ExtensionAttribute>();
    AttributeSpecification specification;
    for (int i = 0; i < specifications.size(); i++) {
        specification = specifications.get(i);
        final ExtensionAttributeAnalyzer analyzer = new ExtensionAttributeAnalyzer();
        analyzer.parse(specification);
        final List<ExtensionAttribute> temp = analyzer.getAttributes();
        if (temp != null) {
            attributes.addAll(temp);
        }
    }
    ExtensionAttribute extensionAttribute;
    for (int i = 0; i < attributes.size(); i++) {
        extensionAttribute = attributes.get(i);
        switch(extensionAttribute.getAttributeType()) {
            case VERSION:
                {
                    final ModuleVersionAttribute moduleVersion = (ModuleVersionAttribute) extensionAttribute;
                    moduleVersion.parse();
                    if (versionNumber != null) {
                        moduleVersion.getLocation().reportSemanticError("Duplicate version attribute");
                    } else {
                        setVersion(moduleVersion.getVersionNumber());
                    }
                    break;
                }
            case REQUIRES:
                {
                    final VersionRequirementAttribute versionReq = (VersionRequirementAttribute) extensionAttribute;
                    versionReq.parse();
                    ImportModule theImport = null;
                    final String requiredModuleName = versionReq.getRequiredModule().getName();
                    for (final ImportModule impMod : importedModules) {
                        if (requiredModuleName.equals(impMod.getIdentifier().getName())) {
                            theImport = impMod;
                            break;
                        }
                    }
                    if (theImport == null) {
                        final String message = MessageFormat.format(ImportModule.MISSINGMODULE, versionReq.getRequiredModule().getDisplayName());
                        versionReq.getRequiredModule().getLocation().reportSemanticError(message);
                    } else {
                        final TTCN3Module theImportedModule = (TTCN3Module) theImport.getReferredModule();
                        // make sure the version attribute is parsed (if any)
                        theImportedModule.check(timestamp);
                        final ProductIdentity requiredVersion = versionReq.getVersionNumber();
                        if (requiredVersion != null && theImportedModule.versionNumber != null && theImportedModule.versionNumber.compareTo(requiredVersion) < 0) {
                            final String message = MessageFormat.format("Module `{0}'' requires version {1} of module `{2}'', but only version {3} is available", identifier.getDisplayName(), requiredVersion.toString(), theImportedModule.getIdentifier().getDisplayName(), theImportedModule.versionNumber.toString());
                            versionReq.getLocation().reportSemanticError(message);
                        }
                    }
                    break;
                }
            case TITANVERSION:
                {
                    final TitanVersionAttribute titanReq = (TitanVersionAttribute) extensionAttribute;
                    titanReq.parse();
                    final ProductIdentity requiredTITANVersion = titanReq.getVersionNumber();
                    final String temp = CompilerVersionInformationCollector.getCompilerProductNumber();
                    final ProductIdentity compilerVersion = ProductIdentityHelper.getProductIdentity(temp, null);
                    if (requiredTITANVersion != null && compilerVersion != null && compilerVersion.compareTo(requiredTITANVersion) < 0) {
                        final String message = MessageFormat.format("Module `{0}'' requires TITAN version {1}, but version {2} is used right now", identifier.getDisplayName(), requiredTITANVersion.toString(), compilerVersion.toString());
                        titanReq.getLocation().reportSemanticError(message);
                    }
                    if (requiredTITANVersion != null && GeneralConstants.ON_THE_FLY_ANALYZER_VERSION != null && GeneralConstants.ON_THE_FLY_ANALYZER_VERSION.compareTo(requiredTITANVersion) < 0) {
                        final String message = MessageFormat.format("Module `{0}'' requires TITAN version {1}, but the on-the-fly analyzer is of version {2}", identifier.getDisplayName(), requiredTITANVersion.toString(), GeneralConstants.ON_THE_FLY_ANALYZER_VERSION.toString());
                        titanReq.getLocation().reportSemanticError(message);
                    }
                    break;
                }
            default:
                // we don't care
                break;
        }
    }
}
Also used : ModuleVersionAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.ModuleVersionAttribute) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) SingleWithAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute) ExtensionAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.ExtensionAttribute) AttributeSpecification(org.eclipse.titan.designer.AST.TTCN3.attributes.AttributeSpecification) VersionRequirementAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.VersionRequirementAttribute) ProductIdentity(org.eclipse.titan.common.product.ProductIdentity) ExtensionAttributeAnalyzer(org.eclipse.titan.designer.parsers.extensionattributeparser.ExtensionAttributeAnalyzer) TitanVersionAttribute(org.eclipse.titan.designer.AST.TTCN3.attributes.TitanVersionAttribute) Qualifiers(org.eclipse.titan.designer.AST.TTCN3.attributes.Qualifiers)

Aggregations

ProductIdentity (org.eclipse.titan.common.product.ProductIdentity)6 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 Path (org.eclipse.core.runtime.Path)1 Status (org.eclipse.core.runtime.Status)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1 AttributeSpecification (org.eclipse.titan.designer.AST.TTCN3.attributes.AttributeSpecification)1 ExtensionAttribute (org.eclipse.titan.designer.AST.TTCN3.attributes.ExtensionAttribute)1 ModuleVersionAttribute (org.eclipse.titan.designer.AST.TTCN3.attributes.ModuleVersionAttribute)1 Qualifiers (org.eclipse.titan.designer.AST.TTCN3.attributes.Qualifiers)1 SingleWithAttribute (org.eclipse.titan.designer.AST.TTCN3.attributes.SingleWithAttribute)1 TitanVersionAttribute (org.eclipse.titan.designer.AST.TTCN3.attributes.TitanVersionAttribute)1 VersionRequirementAttribute (org.eclipse.titan.designer.AST.TTCN3.attributes.VersionRequirementAttribute)1 ExtensionAttributeAnalyzer (org.eclipse.titan.designer.parsers.extensionattributeparser.ExtensionAttributeAnalyzer)1