Search in sources :

Example 41 with IPreferencesService

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

the class IndentAction method performEdits.

@Override
protected void performEdits(final RewriteSessionEditProcessor processor) throws BadLocationException {
    MonoReconciler reconciler = ((TTCNPPEditor) getTargetEditor()).getReconciler();
    reconciler.setIsIncrementalReconciler(false);
    processor.performEdits();
    IPreferencesService prefs = Platform.getPreferencesService();
    reconciler.setIsIncrementalReconciler(prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEINCREMENTALPARSING, false, null));
}
Also used : TTCNPPEditor(org.eclipse.titan.designer.editors.ttcnppeditor.TTCNPPEditor) MonoReconciler(org.eclipse.jface.text.reconciler.MonoReconciler) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 42 with IPreferencesService

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

the class Reconciler method getReconcilerTimeout.

/**
 * Gets the reconciler timeout, or in other words the background thread delay.
 * This is effective only if DELAYSEMANTICCHECKINGTILLSAVE is off,
 * otherwise value is read, but ignored.
 * @return the timeout value in milliseconds
 */
private final int getReconcilerTimeout() {
    IPreferencesService prefs = Platform.getPreferencesService();
    int timeout = prefs.getInt(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.RECONCILERTIMEOUT, 1, null);
    return 1000 * timeout;
}
Also used : IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 43 with IPreferencesService

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

the class ReconcilingStrategy method fullReconciliation.

private void fullReconciliation(final boolean isInitial) {
    actualCode = new StringBuilder(document.get());
    GlobalIntervalHandler.putInterval(document, null);
    IPreferencesService prefs = Platform.getPreferencesService();
    if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null)) {
        analyze(isInitial);
    } else {
        Display.getDefault().asyncExec(new Runnable() {

            @Override
            public void run() {
                List<Position> positions = (new TTCN3FoldingSupport()).calculatePositions(getDocument());
                getEditor().updateFoldingStructure(positions);
                final IFile editedFile = (IFile) editor.getEditorInput().getAdapter(IFile.class);
                if (!MarkerHandler.hasMarker(GeneralConstants.ONTHEFLY_SYNTACTIC_MARKER, editedFile)) {
                    getEditor().refreshOutlinePage();
                }
            }
        });
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) List(java.util.List) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService)

Example 44 with IPreferencesService

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

the class ExportProblems method doExportProblems.

private void doExportProblems() {
    if (!(selection instanceof IStructuredSelection)) {
        return;
    }
    final IStructuredSelection structSelection = (IStructuredSelection) selection;
    if (structSelection.isEmpty()) {
        return;
    }
    final Object firstElement = structSelection.getFirstElement();
    if (!(firstElement instanceof IProject)) {
        ErrorReporter.logError("The export problems command needs to be called on a project ");
        return;
    }
    final IProject project = (IProject) firstElement;
    final IPreferencesService preferencesService = Platform.getPreferencesService();
    final boolean reportDebugInformation = preferencesService.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null);
    if (reportDebugInformation) {
        TITANDebugConsole.println("Problem markers are to export from " + project.getName());
    }
    boolean write = false;
    String fileName;
    final Shell shell = Display.getCurrent().getActiveShell();
    do {
        final FileDialog dialog = new FileDialog(shell, SWT.SAVE);
        dialog.setText("Export problem markers to xls");
        dialog.setFilterExtensions(new String[] { "*.xls" });
        final IPath path = project.getLocation();
        if (path != null) {
            dialog.setFilterPath(path.toPortableString());
        }
        final Calendar now = Calendar.getInstance();
        dialog.setFileName("Problems--" + project.getName() + "--" + now.get(Calendar.YEAR) + "-" + (1 + now.get(Calendar.MONTH)) + "-" + now.get(Calendar.DAY_OF_MONTH));
        fileName = dialog.open();
        if (fileName != null) {
            if (new File(fileName).exists()) {
                write = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "File exist", "This file already exists. Please confirm overwrite.");
            } else {
                write = true;
            }
        } else {
            // User cancelled the file dialog, so we have nothing to do
            return;
        }
    } while (!write);
    final String fileName2 = fileName;
    new ProjectAnalyzerJob("Exporting reported code smells") {

        @Override
        public IStatus doPostWork(final IProgressMonitor monitor) {
            final BaseProblemExporter exporter = new XlsProblemExporter(getProject());
            try {
                exporter.exportMarkers(monitor, fileName2, Calendar.getInstance().getTime());
                if (reportDebugInformation) {
                    TITANDebugConsole.println("Successfully exported markers to xls");
                }
            } catch (IOException e) {
                ErrorReporter.logExceptionStackTrace("Error while exporting", e);
                if (reportDebugInformation) {
                    TITANDebugConsole.println("Failed to write xls");
                }
            }
            return Status.OK_STATUS;
        }
    }.quickSchedule(project);
}
Also used : XlsProblemExporter(org.eclipse.titanium.markers.export.XlsProblemExporter) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) Calendar(java.util.Calendar) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IOException(java.io.IOException) ProjectAnalyzerJob(org.eclipse.titanium.utils.ProjectAnalyzerJob) IProject(org.eclipse.core.resources.IProject) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) BaseProblemExporter(org.eclipse.titanium.markers.export.BaseProblemExporter) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File)

Example 45 with IPreferencesService

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

the class MinimizeVisibilityRefactoring 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