use of org.eclipse.core.runtime.preferences.InstanceScope in project cubrid-manager by CUBRID.
the class CubridStatusMonitorInstance method loadSetting.
/**
* Get the info of StatusMonInstanceData relevant to key from preference
*
* @param key the key relevant to saving instance of StatusMonInstanceData
* @return the instance of StatusMonInstanceData
*/
public StatusMonInstanceData loadSetting(String key) {
StatusMonInstanceData data = null;
synchronized (this) {
IEclipsePreferences preference = new InstanceScope().getNode(CubridManagerUIPlugin.PLUGIN_ID);
byte[] bytes = preference.getByteArray(key, BYTE_ARRAY_DEFAULT_DEFAULT);
if (bytes.length > 0) {
try {
ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(bytes));
data = (StatusMonInstanceData) inputStream.readObject();
inputStream.close();
} catch (Exception ex) {
LOGGER.error(ex.getMessage());
}
}
}
return data;
}
use of org.eclipse.core.runtime.preferences.InstanceScope in project webtools.sourceediting by eclipse.
the class FragmentValidationTools method shouldValidateFragment.
/**
* @param resource
* @return whether to perform validation on a fragment, returning the
* project-specific preference only of project-specific values are
* enabled
*/
static boolean shouldValidateFragment(IResource resource) {
String qualifier = JSPCorePlugin.getDefault().getBundle().getSymbolicName();
IProject project = null;
if (resource.getType() == IResource.PROJECT) {
project = (IProject) resource;
} else {
project = resource.getProject();
}
if (project != null) {
IEclipsePreferences node = new ProjectScope(project).getNode(qualifier);
// first, check whether project specific settings are to be used
boolean useProjectSettings = node.getBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, false);
if (useProjectSettings) {
// only if so, return that value
return node.getBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, true);
}
// if not, return the workspace value
}
return new InstanceScope().getNode(qualifier).getBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, true);
}
use of org.eclipse.core.runtime.preferences.InstanceScope in project webtools.sourceediting by eclipse.
the class JSPActionValidator method loadPreferences.
private void loadPreferences(IFile file) {
fScopes = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
fPreferencesService = Platform.getPreferencesService();
if (file != null && file.isAccessible()) {
ProjectScope projectScope = new ProjectScope(file.getProject());
if (projectScope.getNode(PREFERENCE_NODE_QUALIFIER).getBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, false)) {
fScopes = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
}
}
fSeverityMissingRequiredAttribute = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_MISSING_REQUIRED_ATTRIBUTE);
fSeverityNonEmptyInlineTag = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_NON_EMPTY_INLINE_TAG);
fSeverityUnknownAttribute = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_UNKNOWN_ATTRIBUTE);
fSeverityUnexpectedRuntimeExpression = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_ACTIONS_SEVERITY_UNEXPECTED_RTEXPRVALUE);
}
use of org.eclipse.core.runtime.preferences.InstanceScope in project webtools.sourceediting by eclipse.
the class JSPELValidator method loadPreferences.
private void loadPreferences(IFile file) {
fScopes = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
fPreferencesService = Platform.getPreferencesService();
if (file != null && file.isAccessible()) {
ProjectScope projectScope = new ProjectScope(file.getProject());
if (projectScope.getNode(PREFERENCE_NODE_QUALIFIER).getBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, false)) {
fScopes = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
}
}
}
use of org.eclipse.core.runtime.preferences.InstanceScope in project webtools.sourceediting by eclipse.
the class TLDValidator method validate.
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
if (resource.getType() != IResource.FILE)
return null;
ValidationResult result = new ValidationResult();
IFile file = (IFile) resource;
if (file.isAccessible()) {
// TAGX
if (fTagXexts.contains(file.getFileExtension()) || fTagXnames.contains(file.getName())) {
monitor.beginTask("", 4);
org.eclipse.wst.xml.core.internal.validation.eclipse.Validator xmlValidator = new org.eclipse.wst.xml.core.internal.validation.eclipse.Validator();
ValidationResult result3 = new MarkupValidator().validate(resource, kind, state, new SubProgressMonitor(monitor, 1));
if (monitor.isCanceled())
return result;
ValidationResult result2 = xmlValidator.validate(resource, kind, state, new SubProgressMonitor(monitor, 1));
if (monitor.isCanceled())
return result;
ValidationResult result1 = new JSPActionValidator().validate(resource, kind, state, new SubProgressMonitor(monitor, 1));
List messages = new ArrayList(result1.getReporter(new NullProgressMonitor()).getMessages());
messages.addAll(result2.getReporter(new NullProgressMonitor()).getMessages());
messages.addAll(result3.getReporter(new NullProgressMonitor()).getMessages());
messages.addAll(new JSPDirectiveValidator().validate(resource, kind, state, new SubProgressMonitor(monitor, 1)).getReporter(new NullProgressMonitor()).getMessages());
for (int i = 0; i < messages.size(); i++) {
IMessage message = (IMessage) messages.get(i);
if (message.getText() != null && message.getText().length() > 0) {
ValidatorMessage vmessage = ValidatorMessage.create(message.getText(), resource);
if (message.getAttributes() != null) {
Map attrs = message.getAttributes();
Iterator it = attrs.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
if (!(entry.getValue() instanceof String || entry.getValue() instanceof Integer || entry.getValue() instanceof Boolean)) {
it.remove();
}
}
vmessage.setAttributes(attrs);
}
vmessage.setAttribute(IMarker.LINE_NUMBER, message.getLineNumber());
vmessage.setAttribute(IMarker.MESSAGE, message.getText());
if (message.getOffset() > -1) {
vmessage.setAttribute(IMarker.CHAR_START, message.getOffset());
vmessage.setAttribute(IMarker.CHAR_END, message.getOffset() + message.getLength());
}
int severity = 0;
switch(message.getSeverity()) {
case IMessage.HIGH_SEVERITY:
severity = IMarker.SEVERITY_ERROR;
break;
case IMessage.NORMAL_SEVERITY:
severity = IMarker.SEVERITY_WARNING;
break;
case IMessage.LOW_SEVERITY:
severity = IMarker.SEVERITY_INFO;
break;
}
vmessage.setAttribute(IMarker.SEVERITY, severity);
vmessage.setType(MARKER_TYPE);
result.add(vmessage);
}
}
monitor.done();
} else // TLD
{
try {
final IJavaProject javaProject = JavaCore.create(file.getProject());
if (javaProject.exists()) {
IScopeContext[] scopes = new IScopeContext[] { new InstanceScope(), new DefaultScope() };
ProjectScope projectScope = new ProjectScope(file.getProject());
if (projectScope.getNode(PREFERENCE_NODE_QUALIFIER).getBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, false)) {
scopes = new IScopeContext[] { projectScope, new InstanceScope(), new DefaultScope() };
}
Map[] problems = detectProblems(javaProject, file, scopes);
for (int i = 0; i < problems.length; i++) {
ValidatorMessage message = ValidatorMessage.create(problems[i].get(IMarker.MESSAGE).toString(), resource);
message.setType(MARKER_TYPE);
message.setAttributes(problems[i]);
result.add(message);
}
}
} catch (Exception e) {
Logger.logException(e);
}
}
}
return result;
}
Aggregations