use of org.eclipse.core.runtime.preferences.IPreferencesService in project org.csstudio.display.builder by kasemir.
the class Preferences method getCacheTimeout.
/**
* @return Cache timeout [sec]
*/
public static int getCacheTimeout() {
int timeout = 60;
final IPreferencesService prefs = Platform.getPreferencesService();
if (prefs != null)
timeout = prefs.getInt(ModelPlugin.ID, CACHE_TIMEOUT, timeout, null);
return timeout;
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project liferay-ide by liferay.
the class PortalCore method getPreference.
public static String getPreference(String key) {
IScopeContext[] scopes = new IScopeContext[] { InstanceScope.INSTANCE, DefaultScope.INSTANCE };
IPreferencesService preferencesService = Platform.getPreferencesService();
return preferencesService.getString(PLUGIN_ID, key, null, scopes);
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class ReconcilingStrategy method reconcileSyntax.
/**
* Activates incremental reconciling of the syntax of the specified
* dirty region.
*
* @param dirtyRegion
* the document region which has been changed
*/
public void reconcileSyntax(final DirtyRegion dirtyRegion) {
double parserStart = System.nanoTime();
if (document == null) {
return;
}
int lineBreaks = 0;
try {
if (DirtyRegion.INSERT.equals(dirtyRegion.getType())) {
lineBreaks = calculateLineBreaks(dirtyRegion.getText(), delimeters);
actualCode.insert(dirtyRegion.getOffset(), dirtyRegion.getText());
} else {
lineBreaks = calculateLineBreaks(actualCode.substring(dirtyRegion.getOffset(), dirtyRegion.getOffset() + dirtyRegion.getLength()), delimeters);
actualCode.delete(dirtyRegion.getOffset(), dirtyRegion.getOffset() + dirtyRegion.getLength());
}
} catch (StringIndexOutOfBoundsException e) {
ErrorReporter.logExceptionStackTrace(e);
ErrorReporter.logError("String length: " + actualCode.length() + " region type: " + dirtyRegion.getType() + " region offset: " + dirtyRegion.getOffset() + " region length: " + dirtyRegion.getLength() + " region text: '" + dirtyRegion.getText() + "'\n" + "Actual size of the document: " + document.get().length());
actualCode = new StringBuilder(document.get());
}
if (dirtyRegion.getOffset() == 0 && editor != null && document.getLength() == dirtyRegion.getLength()) {
// thing
if (!editor.isDirty()) {
return;
}
IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null)) {
analyze(false);
}
return;
}
int firstLine;
try {
firstLine = document.getLineOfOffset(dirtyRegion.getOffset());
} catch (BadLocationException e) {
ErrorReporter.logWarningExceptionStackTrace(e);
ErrorReporter.logWarning("Offset became invalid, fallback method used. Document length: " + document.getLength() + " region offset: " + dirtyRegion.getOffset());
firstLine = 0;
}
final IFile editedFile = (IFile) editor.getEditorInput().getAdapter(IFile.class);
if (editedFile == null || ResourceExclusionHelper.isExcluded(editedFile)) {
return;
}
final TTCN3ReparseUpdater reparser;
int length = dirtyRegion.getLength();
if (DirtyRegion.REMOVE.equals(dirtyRegion.getType())) {
reparser = new TTCN3ReparseUpdater(editedFile, actualCode.toString(), firstLine + 1, -1 * lineBreaks, dirtyRegion.getOffset(), dirtyRegion.getOffset() + length, -1 * length);
} else {
reparser = new TTCN3ReparseUpdater(editedFile, actualCode.toString(), firstLine + 1, lineBreaks, dirtyRegion.getOffset(), dirtyRegion.getOffset(), length);
}
final IProject project = editedFile.getProject();
if (project == null) {
return;
}
if (lastIncrementalSyntaxCheck != null) {
try {
lastIncrementalSyntaxCheck.join();
} catch (InterruptedException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
final ProjectSourceParser sourceParser = GlobalParser.getProjectSourceParser(project);
lastIncrementalSyntaxCheck = sourceParser.updateSyntax(editedFile, reparser);
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
if (store.getBoolean(PreferenceConstants.DISPLAYDEBUGINFORMATION)) {
TITANDebugConsole.println("Refreshing the syntax took " + (System.nanoTime() - parserStart) * (1e-9) + " secs");
}
WorkspaceJob op = new WorkspaceJob(FOLDING_UPDATE) {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
// TODO optimize for incremental
// usage
List<Position> positions = (new TTCN3FoldingSupport()).calculatePositions(getDocument());
getEditor().updateFoldingStructure(positions);
}
});
return Status.OK_STATUS;
}
};
op.setPriority(Job.LONG);
op.setSystem(true);
op.setUser(false);
op.setProperty(IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor("titan.gif"));
op.setRule(editedFile);
op.schedule();
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class TTCN3Editor method isSemanticCheckingDelayed.
public static boolean isSemanticCheckingDelayed() {
IPreferencesService prefs = Platform.getPreferencesService();
boolean delayedSemanticChecking = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DELAYSEMANTICCHECKINGTILLSAVE, false, null);
return delayedSemanticChecking;
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class ContentAssistProcessor method computeCompletionProposals.
// FIXME add semantic check guard on project level.
@Override
public ICompletionProposal[] computeCompletionProposals(final ITextViewer viewer, final int offset) {
if (editor == null) {
return new ICompletionProposal[] {};
}
IFile file = (IFile) editor.getEditorInput().getAdapter(IFile.class);
if (file == null) {
return new ICompletionProposal[] {};
}
IDocument doc = viewer.getDocument();
TTCN3ReferenceParser refParser = new TTCN3ReferenceParser(true);
Reference ref = refParser.findReferenceForCompletion(file, offset, doc);
if (ref == null || ref.getSubreferences().isEmpty()) {
return new ICompletionProposal[] {};
}
Scope scope = null;
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
Module tempModule = projectSourceParser.containedModule(file);
String moduleName = null;
if (tempModule != null) {
moduleName = tempModule.getName();
scope = tempModule.getSmallestEnclosingScope(refParser.getReplacementOffset());
ref.setMyScope(scope);
ref.detectModid();
}
IPreferencesService prefs = Platform.getPreferencesService();
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null)) {
TITANDebugConsole.println("parsed the reference: " + ref);
}
TemplateContextType contextType = new TemplateContextType(TTCN3CodeSkeletons.CONTEXT_IDENTIFIER, TTCN3CodeSkeletons.CONTEXT_NAME);
ProposalCollector propCollector = new ProposalCollector(Identifier_type.ID_TTCN, TTCN3CodeSkeletons.CONTEXT_IDENTIFIER, contextType, doc, ref, refParser.getReplacementOffset());
propCollector.setProjectParser(projectSourceParser);
if (moduleName == null) {
// rootless behavior
if (ref.getModuleIdentifier() == null) {
Set<String> moduleNames = projectSourceParser.getKnownModuleNames();
Module module;
for (String name : moduleNames) {
module = projectSourceParser.getModuleByName(name);
if (module != null) {
propCollector.addProposal(name, name, ImageCache.getImage("ttcn.gif"), TTCN3Module.MODULE);
module.getAssignments().addProposal(propCollector);
}
}
} else {
Module module = projectSourceParser.getModuleByName(ref.getModuleIdentifier().getName());
if (module != null) {
module.getAssignments().addProposal(propCollector);
}
}
} else {
/*
* search for the best scope in the module's scope
* hierarchy and call proposal adding function on the
* found scope instead of what can be found here
*/
if (scope != null) {
scope.addProposal(propCollector);
}
}
propCollector.sortTillMarked();
propCollector.markPosition();
if (ref.getSubreferences().size() != 1) {
if (PreferenceConstantValues.SORT_ALPHABETICALLY.equals(sortingpolicy)) {
propCollector.sortAll();
}
return propCollector.getCompletitions();
}
Set<String> knownModuleNames = projectSourceParser.getKnownModuleNames();
for (String knownModuleName : knownModuleNames) {
Identifier tempIdentifier = new Identifier(Identifier_type.ID_NAME, knownModuleName);
Module tempModule2 = projectSourceParser.getModuleByName(knownModuleName);
propCollector.addProposal(tempIdentifier, ImageCache.getImage(tempModule2.getOutlineIcon()), "module");
}
propCollector.sortTillMarked();
propCollector.markPosition();
if (ref.getModuleIdentifier() == null) {
if (scope == null) {
TTCN3CodeSkeletons.addSkeletonProposals(doc, refParser.getReplacementOffset(), propCollector);
} else {
scope.addSkeletonProposal(propCollector);
}
propCollector.addTemplateProposal("refers", new Template("refers( function/altstep/testcase name )", "", propCollector.getContextIdentifier(), "refers( ${fatName} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.addTemplateProposal("derefers", new Template("derefers( function/altstep/testcase name )(parameters)", "", propCollector.getContextIdentifier(), "derefers( ${fatName} ) ( ${parameters} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.sortTillMarked();
propCollector.markPosition();
TTCN3CodeSkeletons.addPredefinedSkeletonProposals(doc, refParser.getReplacementOffset(), propCollector);
if (scope == null) {
TTCN3Keywords.addKeywordProposals(propCollector);
} else {
scope.addKeywordProposal(propCollector);
}
propCollector.sortTillMarked();
propCollector.markPosition();
} else {
if (scope == null || !(scope instanceof StatementBlock)) {
if (PreferenceConstantValues.SORT_ALPHABETICALLY.equals(sortingpolicy)) {
propCollector.sortAll();
}
return propCollector.getCompletitions();
}
String fakeModule = ref.getModuleIdentifier().getName();
if ("any component".equals(fakeModule) || "all component".equals(fakeModule)) {
Component_Type.addAnyorAllProposal(propCollector, 0);
} else if ("any port".equals(fakeModule) || "all port".equals(fakeModule)) {
PortTypeBody.addAnyorAllProposal(propCollector, 0);
} else if ("any timer".equals(fakeModule) || "all timer".equals(fakeModule)) {
Timer.addAnyorAllProposal(propCollector, 0);
}
}
if (PreferenceConstantValues.SORT_ALPHABETICALLY.equals(sortingpolicy)) {
propCollector.sortAll();
}
return propCollector.getCompletitions();
}
Aggregations