use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class LazyficationRefactoring method checkInitialConditions.
@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
final RefactoringStatus result = new RefactoringStatus();
try {
pm.beginTask("Checking preconditions...", 3);
// check "use on the fly parsing", and "minimize memory usage" settings
final IPreferencesService prefs = Platform.getPreferencesService();
if (!prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, false, null)) {
result.addError(ONTHEFLYANALAYSISDISABLED);
}
pm.worked(1);
// check that there are no ttcnpp files in the 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);
// check that there are no error markers in the 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;
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class OpenDeclaration method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
targetEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (targetEditor instanceof ConfigEditor) {
targetEditor = ((ConfigEditor) targetEditor).getEditor();
}
if (targetEditor == null || !(targetEditor instanceof ConfigTextEditor)) {
return null;
}
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(null);
IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
if (file == null) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NOTIDENTIFIABLEFILE);
return null;
}
if (!TITANNature.hasTITANNature(file.getProject())) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(TITANNature.NO_TITAN_FILE_NATURE_FOUND);
return null;
}
int offset;
if (!selection.isEmpty() && selection instanceof TextSelection && !"".equals(((TextSelection) selection).getText())) {
IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null)) {
TITANDebugConsole.println("Selected: " + ((TextSelection) selection).getText());
}
TextSelection textSelection = (TextSelection) selection;
offset = textSelection.getOffset() + textSelection.getLength();
} else {
offset = ((ConfigTextEditor) targetEditor).getCarretOffset();
}
IDocument document = ((ConfigTextEditor) targetEditor).getDocument();
section_type section = getSection(document, offset);
if (section_type.UNKNOWN.equals(section)) {
if (handleModuleParameters(file, offset, document)) {
return null;
}
return null;
} else if (section_type.INCLUDE.equals(section)) {
handleIncludes(file, offset, document);
return null;
} else if (section_type.MODULE_PARAMETERS.equals(section)) {
// identifiable as a module parameter.
if (handleModuleParameters(file, offset, document)) {
return null;
}
}
// Fall back.
handleDefinitions(file, offset, document);
return null;
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class OpenDeclaration method run.
@Override
public void run(final IAction action) {
if (targetEditor instanceof ConfigEditor) {
targetEditor = ((ConfigEditor) targetEditor).getEditor();
}
if (targetEditor == null || !(targetEditor instanceof ConfigTextEditor)) {
return;
}
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(null);
IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
if (file == null) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(NOTIDENTIFIABLEFILE);
return;
}
if (!TITANNature.hasTITANNature(file.getProject())) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(TITANNature.NO_TITAN_FILE_NATURE_FOUND);
return;
}
int offset;
if (!selection.isEmpty() && selection instanceof TextSelection && !"".equals(((TextSelection) selection).getText())) {
IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null)) {
TITANDebugConsole.println("Selected: " + ((TextSelection) selection).getText());
}
TextSelection textSelection = (TextSelection) selection;
offset = textSelection.getOffset() + textSelection.getLength();
} else {
offset = ((ConfigTextEditor) targetEditor).getCarretOffset();
}
IDocument document = ((ConfigTextEditor) targetEditor).getDocument();
section_type section = getSection(document, offset);
if (section_type.UNKNOWN.equals(section)) {
return;
} else if (section_type.INCLUDE.equals(section)) {
handleIncludes(file, offset, document);
return;
} else if (section_type.MODULE_PARAMETERS.equals(section)) {
// identifiable as a module parameter.
if (handleModuleParameters(file, offset, document)) {
return;
}
}
// Fall back.
handleDefinitions(file, offset, document);
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class ReconcilingStrategy method initialReconcile.
@Override
public void initialReconcile() {
GlobalIntervalHandler.putInterval(document, null);
IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null)) {
analyze();
} else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
List<Position> positions = (new ConfigFoldingSupport()).calculatePositions(document);
editor.updateFoldingStructure(positions);
}
});
}
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class OpenDeclaration method doOpenDeclaration.
private final void doOpenDeclaration() {
if (targetEditor == null || !(targetEditor instanceof ASN1Editor)) {
return;
}
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(null);
IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
if (file == null) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(FILENOTIDENTIFIABLE);
return;
}
if (!TITANNature.hasTITANNature(file.getProject())) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(TITANNature.NO_TITAN_FILE_NATURE_FOUND);
return;
}
if (ResourceExclusionHelper.isExcluded(file)) {
MessageDialog.openError(null, "Open Declaration does not work within excluded resources", "This module is excluded from build. To use the Open Declaration " + "feature please click on the 'Toggle exclude from build state' in the context menu of the Project Explorer. ");
return;
}
IPreferencesService prefs = Platform.getPreferencesService();
boolean reportDebugInformation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null);
int offset;
if (!selection.isEmpty() && selection instanceof TextSelection && !"".equals(((TextSelection) selection).getText())) {
if (reportDebugInformation) {
TITANDebugConsole.println("text selected: " + ((TextSelection) selection).getText());
}
TextSelection tSelection = (TextSelection) selection;
offset = tSelection.getOffset() + tSelection.getLength();
} else {
offset = ((ASN1Editor) targetEditor).getCarretOffset();
}
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
final Module module = projectSourceParser.containedModule(file);
if (module == null) {
// TODO: How could this happen??? (NPE occured)
return;
}
IdentifierFinderVisitor visitor = new IdentifierFinderVisitor(offset);
module.accept(visitor);
final Declaration decl = visitor.getReferencedDeclaration();
if (decl == null) {
if (reportDebugInformation) {
TITANDebugConsole.println("No visible elements found");
}
return;
}
selectAndRevealDeclaration(decl.getIdentifier().getLocation());
}
Aggregations