Search in sources :

Example 76 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.

the class PermittedAlphabetConstraint method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(CompilationTimeStamp timestamp) {
    // Not Yet supported
    final IPreferencesService preferenceService = Platform.getPreferencesService();
    final String option = preferenceService.getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNSUPPORTEDCONSTRUCTS, GeneralConstants.WARNING, null);
    myType.getLocation().reportConfigurableSemanticProblem(option, "Permitted alphabet constraint not yet supported");
}
Also used : IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 77 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.

the class TITANBuilder method build.

/**
 * Please let the code below explain itself.
 * <p>
 * Process:
 * <ul>
 * <li>The resource delta is checked for changes and the project's files
 * are collected.
 * <li>Project settings are evaluated and Markers are deleted from the
 * collected files.
 * <li>Even in case of autobuild we force the compiler to check the
 * files, by deleting the .compile file.
 * <li>If the makefile must be regenerated then, the makefile generating
 * command and the makefile updater script's command are created
 * <li>The dependency updating command is created if automatic
 * dependency update is not turned of by the user explicitly.
 * <li>The make command is created.
 * <li>A new TITANJob is scheduled to execute the created commands.
 * </ul>
 *
 * @see TITANJob
 *
 * @param kind
 *                the kind of build being requested. Valid values are
 *                <ul>
 *                <li>{@link #FULL_BUILD} - indicates a full build.</li>
 *                <li>{@link #INCREMENTAL_BUILD}- indicates an
 *                incremental build.</li> <li>{@link #AUTO_BUILD} -
 *                indicates an automatically triggered incremental build
 *                (autobuilding on).</li>
 *                </ul>
 * @param args
 *                a table of builder-specific arguments keyed by
 *                argument name
 * @param monitor
 *                the progress monitor to report errors to.
 * @return the list of projects for which this builder would like deltas
 *         the next time it is run or <code>null</code> if none
 * @exception CoreException
 *                    if this build fails.
 */
@Override
protected IProject[] build(final int kind, @SuppressWarnings("rawtypes") final Map args, final IProgressMonitor monitor) throws CoreException {
    IProject project = getProject();
    if (!TITANInstallationValidator.check(true)) {
        return project.getReferencedProjects();
    }
    if (!LicenseValidator.check()) {
        return project.getReferencedProjects();
    }
    if (Cygwin.isMissingInOSWin32()) {
        ErrorReporter.logError(MISSING_CYGWIN);
        return project.getReferencedProjects();
    }
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    boolean reportDebugInformation = store.getBoolean(PreferenceConstants.DISPLAYDEBUGINFORMATION);
    final SubMonitor progress = SubMonitor.convert(monitor);
    String consoleActionBeforeBuild = store.getString(PreferenceConstants.CONSOLE_ACTION_BEFORE_BUILD);
    if (PreferenceConstantValues.BEFORE_BUILD_PRINT_CONSOLE_DELIMITERS.equals(consoleActionBeforeBuild)) {
        String timeStamp = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss").format(Calendar.getInstance().getTime());
        TITANConsole.println("**************************************************************" + "\n" + timeStamp + ": starting to build " + project.getName() + "\n**************************************************************");
    } else if (PreferenceConstantValues.BEFORE_BUILD_CLEAR_CONSOLE.equals(consoleActionBeforeBuild)) {
        TITANConsole.clearConsole();
    }
    if (store.getBoolean(PreferenceConstants.TREATONTHEFLYERRORSFATALFORBUILD)) {
        // IF the option to treat on-the-fly errors as fatal for
        // build was set, and we find an error marker, quit the build.
        IMarker[] markers = project.findMarkers(GeneralConstants.ONTHEFLY_SYNTACTIC_MARKER, true, IResource.DEPTH_INFINITE);
        for (IMarker marker : markers) {
            if (IMarker.SEVERITY_ERROR == marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR)) {
                TITANConsole.println("Build failed because of syntactical errors");
                return project.getReferencedProjects();
            }
        }
        markers = project.findMarkers(GeneralConstants.ONTHEFLY_SEMANTIC_MARKER, true, IResource.DEPTH_INFINITE);
        for (IMarker marker : markers) {
            if (IMarker.SEVERITY_ERROR == marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR)) {
                TITANConsole.println("Build failed because of semantic errors");
                return project.getReferencedProjects();
            }
        }
        markers = project.findMarkers(GeneralConstants.ONTHEFLY_MIXED_MARKER, true, IResource.DEPTH_INFINITE);
        for (IMarker marker : markers) {
            if (IMarker.SEVERITY_ERROR == marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR)) {
                TITANConsole.println("Build failed because of mixed errors");
                return project.getReferencedProjects();
            }
        }
    }
    MarkerHandler.markMarkersForRemoval(GeneralConstants.COMPILER_ERRORMARKER, project);
    if (!ProjectSourceParser.checkConfigurationRequirements(project, GeneralConstants.COMPILER_ERRORMARKER)) {
        TITANConsole.println("Build failed because of build configuration error. See view 'Error Log' for details.");
        return project.getReferencedProjects();
    }
    if (!ProjectBasedBuilder.getProjectBasedBuilder(project).checkCodeSplittingEquality()) {
        TITANConsole.println("Build failed because of code splitting setting error.\n" + "Code splitting settings shall be the same. See view 'Error Log' for details.");
        return project.getReferencedProjects();
    }
    MarkerHandler.removeAllMarkedMarkers(project);
    if (reportDebugInformation) {
        TITANDebugConsole.println("starting to build " + project.getName());
    }
    progress.beginTask("Build", 6);
    IProgressMonitor initialisationMonitor = progress.newChild(1);
    initialisationMonitor.beginTask("Checking prerequisites", 3);
    if (!isBuilderEnabled(project)) {
        initialisationMonitor.done();
        progress.done();
        if (reportDebugInformation) {
            TITANDebugConsole.println("Finished building " + project.getName());
        }
        return project.getReferencedProjects();
    }
    initialisationMonitor.worked(1);
    IPath workingDir = ProjectBasedBuilder.getProjectBasedBuilder(project).getWorkingDirectoryPath(true);
    if (workingDir == null) {
        ErrorReporter.logError("The working directory could not be created because it hasn't been defined yet");
        initialisationMonitor.done();
        progress.done();
        if (reportDebugInformation) {
            TITANDebugConsole.println("Finished building " + project.getName());
        }
        return project.getReferencedProjects();
    }
    File file = new File(workingDir.toOSString());
    if (!file.exists()) {
        file.mkdirs();
    }
    final IContainer[] workingDirectories = ProjectBasedBuilder.getProjectBasedBuilder(project).getWorkingDirectoryResources(true);
    for (IContainer workingDirectory : workingDirectories) {
        if (workingDirectory != null) {
            if (!workingDirectory.isSynchronized(IResource.DEPTH_ZERO)) {
                workingDirectory.refreshLocal(IResource.DEPTH_ZERO, null);
            }
            if (workingDirectory.isAccessible() && !workingDirectory.isDerived()) {
                try {
                    workingDirectory.setDerived(true, null);
                } catch (CoreException e) {
                    ErrorReporter.logExceptionStackTrace(e);
                }
            }
        }
    }
    String targetExecutable = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.TARGET_EXECUTABLE_PROPERTY));
    if (targetExecutable != null && targetExecutable.length() != 0) {
        URI uri = TITANPathUtilities.resolvePathURI(targetExecutable, project.getLocation().toOSString());
        IPath path = URIUtil.toPath(uri);
        path = path.removeLastSegments(1);
        targetExecutable = path.toOSString();
        file = new File(targetExecutable);
        if (!file.exists()) {
            if (!file.mkdirs()) {
                ErrorReporter.logError("The folder to contain the generated executable could not be created");
            }
        }
    }
    initialisationMonitor.worked(1);
    TITANBuilderResourceDeltaVisitor deltavisitor = getDeltaVisitor(getDelta(project));
    // Makefile needs to be rebuilt if a new resource has been added
    // to or an existing one
    // has been deleted from the project.
    boolean mandatoryMakefileRebuild = deltavisitor.needsMakefileRebuild() || ProjectBasedBuilder.getForcedMakefileRebuild(project);
    int nofChangedResources = deltavisitor.getChangedResources().size();
    if (ProjectBasedBuilder.getForcedBuild(project) || mandatoryMakefileRebuild) {
        nofChangedResources++;
    }
    if (mandatoryMakefileRebuild) {
        IProject[] referencingProjects = ProjectBasedBuilder.getProjectBasedBuilder(project).getReferencingProjects();
        for (int i = 0; i < referencingProjects.length; i++) {
            ProjectBasedBuilder.setForcedMakefileRebuild(referencingProjects[i]);
        }
    }
    ProjectBasedBuilder.clearForcedBuild(project);
    ProjectBasedBuilder.clearForcedMakefileRebuild(project);
    // to check the source code and place back markers.
    if (nofChangedResources == 0 && kind != FULL_BUILD) {
        initialisationMonitor.done();
        progress.done();
        if (reportDebugInformation) {
            TITANDebugConsole.println("Finished building " + project.getName());
        }
        return project.getReferencedProjects();
    }
    initialisationMonitor.worked(1);
    TITANBuilderResourceVisitor visitor = ProjectBasedBuilder.getProjectBasedBuilder(project).getResourceVisitor();
    Map<String, IFile> files = visitor.getFiles();
    initialisationMonitor.done();
    final TITANJob buildJob = new TITANJob(BUILD_PROCESS, files, workingDir.toFile(), project);
    buildJob.setPriority(Job.DECORATE);
    buildJob.setUser(true);
    buildJob.setRule(project);
    buildJob.removeCompilerMarkers();
    buildJob.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(final IJobChangeEvent event) {
            try {
                boolean buildSucceeded = buildJob.getResult().isOK();
                getProject().setSessionProperty(GeneralConstants.PROJECT_UP_TO_DATE, buildSucceeded);
                TITANDecorator.refreshSelectively(getProject());
            } catch (CoreException e) {
                ErrorReporter.logExceptionStackTrace("While setting `" + getProject().getName() + "' as up-to-date", e);
            }
        }
    });
    if (PreferenceConstantValues.ONTHEFLYOPTIONREMOVE.equals(store.getString(PreferenceConstants.ONTHEFLYMARKERSAFTERCOMPILER))) {
        buildJob.removeOnTheFlyMarkers();
    }
    final SubMonitor symboliclinkMonitor = progress.newChild(1);
    symboliclinkMonitor.beginTask("Refreshing symbolic links", 3);
    SymbolicLinkHandler.copyExternalFileToWorkingDirectory(files, workingDir.toOSString(), symboliclinkMonitor.newChild(1));
    boolean automaticMakefileGeneration = ProjectBuildPropertyData.useAutomaticMakefilegeneration(project);
    boolean useInternalMakefileGeneration = ProjectBuildPropertyData.useInternalMakefilegeneration(project);
    boolean useSymbolicLinks = ProjectBuildPropertyData.useSymbolicLinks(project);
    if (useSymbolicLinks) {
        SymbolicLinkHandler.addSymlinkRemovingCommandForRemovedFiles(workingDir.toOSString(), buildJob, deltavisitor.getLastTimeRemovedFiles(), symboliclinkMonitor.newChild(1));
        SymbolicLinkHandler.addSymlinkCreationCommand(files, workingDir.toOSString(), buildJob, deltavisitor.getLastTimeRemovedFiles(), symboliclinkMonitor.newChild(1), automaticMakefileGeneration);
    }
    symboliclinkMonitor.done();
    Map<String, IFile> filesOfReferencedProjects = ProjectBasedBuilder.getProjectBasedBuilder(project).getFilesofReferencedProjects();
    if (files.isEmpty() && visitor.getCentralStorageFiles().isEmpty() && filesOfReferencedProjects.isEmpty()) {
        buildJob.schedule();
        if (reportDebugInformation) {
            TITANDebugConsole.println("Finished building " + project.getName());
        }
        return project.getReferencedProjects();
    }
    final SubMonitor filepreparserMonitor = progress.newChild(1);
    filepreparserMonitor.beginTask("removing markers from files", files.size());
    if (PreferenceConstantValues.ONTHEFLYOPTIONREMOVE.equals(store.getString(PreferenceConstants.ONTHEFLYMARKERSAFTERCOMPILER))) {
        List<IFile> outdatedFiles = new ArrayList<IFile>();
        List<IFile> semanticallyOutdatedFiles = new ArrayList<IFile>();
        for (IFile tempFile : files.values()) {
            // arbitrary file.
            try {
                if (tempFile.findMarkers(GeneralConstants.ONTHEFLY_SYNTACTIC_MARKER, true, IResource.DEPTH_INFINITE).length != 0 || tempFile.findMarkers(GeneralConstants.ONTHEFLY_TASK_MARKER, true, IResource.DEPTH_INFINITE).length != 0) {
                    outdatedFiles.add(tempFile);
                }
                if (tempFile.findMarkers(GeneralConstants.ONTHEFLY_SEMANTIC_MARKER, true, IResource.DEPTH_INFINITE).length != 0) {
                    semanticallyOutdatedFiles.add(tempFile);
                }
            } catch (CoreException e) {
                ErrorReporter.logExceptionStackTrace("While deleting markers from `" + tempFile.getName() + "'", e);
            }
            filepreparserMonitor.worked(1);
        }
        if (!outdatedFiles.isEmpty()) {
            GlobalParser.getProjectSourceParser(project).reportOutdating(outdatedFiles);
        }
        if (!semanticallyOutdatedFiles.isEmpty()) {
            GlobalParser.getProjectSourceParser(project).reportSemanticOutdating(semanticallyOutdatedFiles);
        }
    }
    filepreparserMonitor.done();
    IPath makefile = new Path(workingDir.toOSString() + File.separatorChar + MAKEFILE);
    boolean makefileExists = makefile.toFile().exists();
    // It is true if the makefile is going to exist before the build
    // is started
    boolean makefileWillExist = automaticMakefileGeneration && (mandatoryMakefileRebuild || !makefileExists);
    if (makefileWillExist) {
        if (!useInternalMakefileGeneration) {
            IProject[] projects = project.getReferencedProjects();
            for (IProject referencedProject : projects) {
                if (!ProjectBuildPropertyData.useSymbolicLinks(referencedProject)) {
                    ErrorReporter.logError("Can not generate a makefile to project `" + project.getName() + "' with the external makefile generator as project `" + referencedProject.getName() + "' is set to build without generating symbolic links");
                    return projects;
                }
            }
        }
        createMakefile(buildJob);
    }
    String buildLevel = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakeAttributesData.BUILD_LEVEL_PROPERTY));
    if (buildLevel == null) {
        buildLevel = MakeAttributesData.BUILD_LEVEL_5;
        project.setPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakeAttributesData.BUILD_LEVEL_PROPERTY), MakeAttributesData.BUILD_LEVEL_5);
    }
    buildLevel = MakeAttributesData.getBuildLevel(buildLevel);
    if (makefileExists || makefileWillExist) {
        List<String> command = new ArrayList<String>();
        String makeFlags = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakeAttributesData.TEMPORAL_MAKEFILE_FLAGS_PROPERTY));
        String dynamicLinking = project.getPersistentProperty(new QualifiedName(ProjectBuildPropertyData.QUALIFIER, MakefileCreationData.DYNAMIC_LINKING_PROPERTY));
        // Setting proper command for the build level.
        String makeCommand = null;
        if (MakeAttributesData.BUILD_LEVEL_5.equals(buildLevel)) {
            command.add(MAKE_DEP);
            makeCommand = MAKE_DEP;
            buildJob.addCommand(command, makeCommand);
            command = new ArrayList<String>();
            command.add(MAKE_ALL);
            makeCommand = MAKE_ALL;
        } else if (MakeAttributesData.BUILD_LEVEL_4_5.equals(buildLevel)) {
            if (GlobalProjectStructureTracker.dependencyChanged(project) || deltavisitor.getUnAnalyzedFileChanged()) {
                command.add(MAKE_DEP);
                makeCommand = MAKE_DEP;
                buildJob.addCommand(command, makeCommand);
                command = new ArrayList<String>();
            }
            command.add(MAKE_ALL);
            makeCommand = MAKE_ALL;
        } else if (MakeAttributesData.BUILD_LEVEL_4.equals(buildLevel)) {
            command.add(MAKE);
            makeCommand = MAKE;
        } else if (MakeAttributesData.BUILD_LEVEL_3.equals(buildLevel)) {
            command.add(MAKE_DEP);
            makeCommand = MAKE_DEP;
            buildJob.addCommand(command, makeCommand);
            command = new ArrayList<String>();
            if (dynamicLinking != null && TRUE.equals(dynamicLinking)) {
                command.add(MAKE_SHARED_OBJECTS);
                makeCommand = MAKE_SHARED_OBJECTS;
            } else {
                command.add(MAKE_OBJECTS);
                makeCommand = MAKE_OBJECTS;
            }
        } else if (MakeAttributesData.BUILD_LEVEL_2_5.equals(buildLevel)) {
            if (GlobalProjectStructureTracker.dependencyChanged(project) || deltavisitor.getUnAnalyzedFileChanged()) {
                command.add(MAKE_DEP);
                makeCommand = MAKE_DEP;
                buildJob.addCommand(command, makeCommand);
                command = new ArrayList<String>();
            }
            if (dynamicLinking != null && TRUE.equals(dynamicLinking)) {
                command.add(MAKE_SHARED_OBJECTS);
                makeCommand = MAKE_SHARED_OBJECTS;
            } else {
                command.add(MAKE_OBJECTS);
                makeCommand = MAKE_OBJECTS;
            }
        } else if (MakeAttributesData.BUILD_LEVEL_2.equals(buildLevel)) {
            if (dynamicLinking != null && TRUE.equals(dynamicLinking)) {
                command.add(MAKE_SHARED_OBJECTS);
                makeCommand = MAKE_SHARED_OBJECTS;
            } else {
                command.add(MAKE_OBJECTS);
                makeCommand = MAKE_OBJECTS;
            }
        } else if (MakeAttributesData.BUILD_LEVEL_1.equals(buildLevel)) {
            command.add(MAKE_COMPILE);
            makeCommand = MAKE_COMPILE;
        } else if (MakeAttributesData.BUILD_LEVEL_0.equals(buildLevel)) {
            command.add(MAKE_CHECK);
            makeCommand = MAKE_CHECK;
        } else {
            command.add(MAKE_DEP);
            makeCommand = MAKE_DEP;
            buildJob.addCommand(command, makeCommand);
            command = new ArrayList<String>();
            command.add(MAKE_ALL);
            makeCommand = MAKE_ALL;
        }
        int availableProcessors = Runtime.getRuntime().availableProcessors();
        IPreferencesService prefs = Platform.getPreferencesService();
        int processingUnitsToUse = prefs.getInt(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.PROCESSINGUNITSTOUSE, availableProcessors, null);
        if (processingUnitsToUse > 1) {
            command.add(" -j " + processingUnitsToUse);
        }
        if (processingUnitsToUse < availableProcessors) {
            TITANConsole.println(MessageFormat.format(FEWPROCESSINGUNITTOUSESET, processingUnitsToUse, availableProcessors));
        }
        if (makeFlags != null && !EMPTY_STRING.equals(makeFlags) && makeFlags.length() > 0) {
            command.add(makeFlags);
        }
        buildJob.addCommand(command, makeCommand);
    } else {
        TITANConsole.println(BUILD_WITHOUT_MAKEFILE_ERROR + project.getName());
        ErrorReporter.logError(BUILD_WITHOUT_MAKEFILE_ERROR + project.getName());
    }
    IStatus status = buildJob.runInWorkspace(progress.newChild(3));
    try {
        project.setSessionProperty(GeneralConstants.PROJECT_UP_TO_DATE, status.isOK());
        TITANDecorator.refreshSelectively(project);
    } catch (CoreException e) {
        ErrorReporter.logExceptionStackTrace("While setting project `" + project.getName() + "' up-to-date", e);
    }
    if (reportDebugInformation) {
        TITANDebugConsole.println("Finished building " + project.getName());
    }
    progress.done();
    if (buildJob.foundErrors() || progress.isCanceled()) {
        if (kind == FULL_BUILD || kind == INCREMENTAL_BUILD) {
            final IProject project2 = project;
            WorkspaceJob op = new WorkspaceJob("Touching the project") {

                @Override
                public IStatus runInWorkspace(final IProgressMonitor monitor) {
                    try {
                        project2.touch(null);
                    } catch (CoreException e) {
                        ErrorReporter.logExceptionStackTrace("While touching project `" + project2.getName() + "'", e);
                    }
                    return Status.OK_STATUS;
                }
            };
            op.setPriority(Job.SHORT);
            op.setRule(project2.getWorkspace().getRoot());
            op.setSystem(true);
            op.setUser(false);
            op.setProperty(IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor(TITAN_GIF));
            op.schedule();
        }
    }
    return project.getReferencedProjects();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) ArrayList(java.util.ArrayList) URI(java.net.URI) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) IContainer(org.eclipse.core.resources.IContainer) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) QualifiedName(org.eclipse.core.runtime.QualifiedName) SubMonitor(org.eclipse.core.runtime.SubMonitor) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) IProject(org.eclipse.core.resources.IProject) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IMarker(org.eclipse.core.resources.IMarker) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) SimpleDateFormat(java.text.SimpleDateFormat) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 78 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.

the class ExternalTitanAction method getCompilerPath.

protected final Path getCompilerPath() {
    final IPreferencesService prefs = Platform.getPreferencesService();
    final String pathOfTITAN = prefs.getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.TITAN_INSTALLATION_PATH, "", null);
    return new Path(pathOfTITAN + COMPILER_SUBPATH);
}
Also used : Path(org.eclipse.core.runtime.Path) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 79 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.

the class FindDefinitionAction method doFindDefinition.

private void doFindDefinition() {
    final DefinitionListSelectionDialog dialog = new DefinitionListSelectionDialog(Display.getDefault().getActiveShell(), new DefinitionLabelProvider(), getCurrentProject());
    dialog.setTitle("Find Definition");
    dialog.setMessage("Type the name of a definition");
    dialog.setHelpAvailable(false);
    if (targetEditor instanceof TTCN3Editor) {
        selection = ((TTCN3Editor) targetEditor).getSelectionProvider().getSelection();
    }
    if (selection instanceof TextSelection && !selection.isEmpty()) {
        final IPreferencesService prefs = Platform.getPreferencesService();
        final boolean reportDebugInformation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null);
        if (reportDebugInformation) {
            TITANDebugConsole.println("text selected: " + ((TextSelection) selection).getText());
        }
        final TextSelection tSelection = (TextSelection) selection;
        dialog.setFilter(tSelection.getText());
    }
    dialog.init();
    if (dialog.open() == Window.CANCEL || dialog.getFirstResult() == null) {
        return;
    }
    final Object result = dialog.getFirstResult();
    if (!(result instanceof ILocateableNode)) {
        return;
    }
    showInEditor((ILocateableNode) result);
}
Also used : TTCN3Editor(org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor) DefinitionListSelectionDialog(org.eclipse.titan.designer.finddefinition.DefinitionListSelectionDialog) TextSelection(org.eclipse.jface.text.TextSelection) ILocateableNode(org.eclipse.titan.designer.AST.ILocateableNode) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 80 with IPreferencesService

use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.

the class OrganizeImportsRefactoring method checkInitialConditions.

@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
    final RefactoringStatus result = new RefactoringStatus();
    try {
        pm.beginTask("Checking preconditions...", 2);
        // PreferenceConstants.USEONTHEFLYPARSING
        final IPreferencesService prefs = Platform.getPreferencesService();
        if (!prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, false, null)) {
            result.addError(ONTHEFLYANALAYSISDISABLED);
        }
        // project
        for (IProject project : projects) {
            if (hasTtcnppFiles(project)) {
                // FIXME actually all referencing and referenced projects need to be checked too !
                result.addError(MessageFormat.format(PROJECTCONTAINSTTCNPPFILES, project));
            }
        }
        pm.worked(1);
        // project
        for (IProject project : projects) {
            final IMarker[] markers = project.findMarkers(null, true, IResource.DEPTH_INFINITE);
            for (IMarker marker : markers) {
                if (IMarker.SEVERITY_ERROR == marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR)) {
                    result.addError(MessageFormat.format(PROJECTCONTAINSERRORS, project));
                    break;
                }
            }
        }
        pm.worked(1);
    } catch (CoreException e) {
        ErrorReporter.logExceptionStackTrace(e);
        result.addFatalError(e.getMessage());
    } finally {
        pm.done();
    }
    return result;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IMarker(org.eclipse.core.resources.IMarker) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) IProject(org.eclipse.core.resources.IProject)

Aggregations

IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)96 IFile (org.eclipse.core.resources.IFile)26 ArrayList (java.util.ArrayList)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)14 IProject (org.eclipse.core.resources.IProject)13 CoreException (org.eclipse.core.runtime.CoreException)13 Module (org.eclipse.titan.designer.AST.Module)11 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)11 List (java.util.List)10 File (java.io.File)8 TextSelection (org.eclipse.jface.text.TextSelection)8 Path (org.eclipse.core.runtime.Path)6 IContainer (org.eclipse.core.resources.IContainer)5 IMarker (org.eclipse.core.resources.IMarker)5 IPath (org.eclipse.core.runtime.IPath)5 SubMonitor (org.eclipse.core.runtime.SubMonitor)5 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)5 IOException (java.io.IOException)4 IStatus (org.eclipse.core.runtime.IStatus)4