use of org.eclipse.core.runtime.preferences.IPreferencesService in project org.csstudio.display.builder by kasemir.
the class Preferences method getTimespanShortcuts.
/**
* @return Array where [N][0] is display text and [N][1] is the 'start' time
*/
public static String[][] getTimespanShortcuts() {
String shortcuts = "1 Day,-1 days|7 Days,-7 days";
final IPreferencesService prefs = Platform.getPreferencesService();
if (prefs != null)
shortcuts = prefs.getString(Activator.PLUGIN_ID, TIME_SPAN_SHORTCUTS, shortcuts, null);
final List<List<String>> items = new ArrayList<>();
for (String item : shortcuts.split("\\|")) {
final String[] display_start = item.split(", *");
if (display_start.length != 2) {
Activator.getLogger().log(Level.WARNING, "Invalid " + TIME_SPAN_SHORTCUTS + " value " + item);
continue;
}
items.add(Arrays.asList(display_start));
}
final String[][] result = new String[items.size()][2];
for (int i = 0; i < items.size(); ++i) {
result[i][0] = items.get(i).get(0);
result[i][1] = items.get(i).get(1);
}
return result;
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project org.csstudio.display.builder by kasemir.
the class Preferences method getArchiveServerURLs.
public static ArchiveServerURL[] getArchiveServerURLs() {
final IPreferencesService prefs = Platform.getPreferencesService();
final String urls = prefs.getString(Activator.PLUGIN_ID, URLS, "", null).trim();
if (urls.length() <= 0)
return new ArchiveServerURL[0];
ArrayList<ArchiveServerURL> list = new ArrayList<ArchiveServerURL>();
for (String fragment : urls.split("\\*")) {
String[] strs = fragment.split("\\|");
if (strs.length == 1)
list.add(new ArchiveServerURL(strs[0], null));
else if (strs.length >= 2)
list.add(new ArchiveServerURL(strs[0], strs[1]));
}
return list.toArray(new ArchiveServerURL[list.size()]);
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project eclipse-integration-commons by spring-projects.
the class CorePlugin method getUUID.
public static synchronized String getUUID() {
ServiceReference ref = getDefault().getBundle().getBundleContext().getServiceReference(IPreferencesService.class.getName());
IPreferencesService prefService = (IPreferencesService) getDefault().getBundle().getBundleContext().getService(ref);
try {
IEclipsePreferences prefs = (IEclipsePreferences) prefService.getRootNode().node(InstanceScope.SCOPE);
Preferences p = prefs.node(PLUGIN_ID);
if (StringUtils.isEmpty(p.get(UUID_PROPERTY_KEY, ""))) {
p.put(UUID_PROPERTY_KEY, UUID.randomUUID().toString());
}
return p.get(UUID_PROPERTY_KEY, "");
} finally {
if (prefService != null) {
getDefault().getBundle().getBundleContext().ungetService(ref);
}
}
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project mdw-designer by CenturyLinkCloud.
the class WorkspaceConfigurator method loadPreferences.
/**
* Loads preferences from the workspace setup site.
*
* @return <code>true</code> if the load was successful
*/
protected boolean loadPreferences() {
// import all
IPreferenceFilter[] filters = new IPreferenceFilter[1];
filters[0] = new IPreferenceFilter() {
public String[] getScopes() {
return new String[] { InstanceScope.SCOPE, ConfigurationScope.SCOPE };
}
public Map<String, PreferenceFilterEntry[]> getMapping(String scope) {
return null;
}
};
String baseUrl = getWorkspaceConfig().getMdwSettings().getWorkspaceSetupUrl();
if (!baseUrl.endsWith("/"))
baseUrl += "/";
InputStream is = null;
try {
URL url = new URL(baseUrl + "MdwWorkspaceSetup.epf");
URLConnection connection = url.openConnection();
is = connection.getInputStream();
IPreferencesService service = Platform.getPreferencesService();
IExportedPreferences prefs = service.readPreferences(is);
service.applyPreferences(prefs, filters);
} catch (Exception ex) {
PluginMessages.uiError(getShell(), ex, "Workspace Setup");
return false;
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
// do nothing
}
}
}
return true;
}
use of org.eclipse.core.runtime.preferences.IPreferencesService in project titan.EclipsePlug-ins by eclipse.
the class Activator method batchedEventHandler.
/**
* Handle the resource changes that has been batched.
*/
protected void batchedEventHandler() {
projects = new HashMap<IProject, IResourceDelta>();
for (final IResourceChangeEvent event : BATCHED_EVENTS) {
final IResourceDelta resourceDelta = event.getDelta();
if (resourceDelta == null) {
switch(event.getType()) {
case IResourceChangeEvent.PRE_CLOSE:
case IResourceChangeEvent.PRE_DELETE:
GlobalParser.clearAllInformation(event.getResource().getProject());
break;
default:
break;
}
} else {
try {
resourceDelta.accept(projectAdder);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
MarkerHandler.handleResourceChanges(event);
}
}
BATCHED_EVENTS.clear();
final IPreferencesService prefs = Platform.getPreferencesService();
// for every project check if the TITANProperties file was changed or need to be changed
for (final IProject project : projects.keySet()) {
// which can be handled
if (project != null && project.isAccessible() && projects.get(project) != null) {
final IResourceDelta projectDelta = projects.get(project);
if (projectDelta.getKind() == IResourceDelta.ADDED) {
// new project appeared load the settings
final ProjectFileHandler pfHandler = new ProjectFileHandler(project);
pfHandler.loadProjectSettings();
PropertyNotificationManager.firePropertyChange(project);
continue;
}
try {
final IResourceDelta propertiesDelta = projectDelta.findMember(new Path(ProjectFileHandler.XML_TITAN_PROPERTIES_FILE));
final DeltaVisitor visitor = new DeltaVisitor();
projectDelta.accept(visitor);
if (visitor.hasNewOrRemovedResources()) {
final ProjectFileHandler pfHandler = new ProjectFileHandler(project);
if (propertiesDelta == null || propertiesDelta.getKind() == IResourceDelta.REMOVED) {
// project setting file does not exist
pfHandler.saveProjectSettings();
} else {
// the project settings have changed and we have new resources, the project was updated by the user
pfHandler.loadProjectSettings();
PropertyNotificationManager.firePropertyChange(project);
}
} else {
if (propertiesDelta != null) {
final ProjectFileHandler pfHandler = new ProjectFileHandler(project);
if (propertiesDelta.getKind() == IResourceDelta.REMOVED) {
// save the settings if the only change was that it was removed externally
pfHandler.saveProjectSettings();
} else {
// load the settings if it changed
pfHandler.loadProjectSettings();
PropertyNotificationManager.firePropertyChange(project);
}
}
}
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
// check if it needs to be built, if full analysis is needed, and that the working directory is always set as derived
final IProject[] referencingProjects = ProjectBasedBuilder.getProjectBasedBuilder(project).getReferencingProjects();
for (int i = 0; i < referencingProjects.length; i++) {
ProjectBasedBuilder.setForcedBuild(referencingProjects[i]);
}
if ((projectDelta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
TITANBuilder.markProjectForRebuild(project);
}
if (projectDelta.getKind() == IResourceDelta.ADDED) {
final WorkspaceJob derivedSetter = new WorkspaceJob("Derived flag setter") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) {
final IContainer[] workingDirectories = ProjectBasedBuilder.getProjectBasedBuilder(project).getWorkingDirectoryResources(true);
for (IContainer workingDirectory : workingDirectories) {
if (workingDirectory != null && workingDirectory.isAccessible()) {
try {
workingDirectory.setDerived(true, monitor);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
}
return Status.OK_STATUS;
}
};
derivedSetter.setPriority(Job.LONG);
derivedSetter.setUser(false);
derivedSetter.setSystem(true);
derivedSetter.setRule(project.getWorkspace().getRuleFactory().modifyRule(project));
derivedSetter.setProperty(IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor("titan.gif"));
derivedSetter.schedule();
}
}
}
// we need to invoke the analyzer to refresh the information databases.
if (prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.USEONTHEFLYPARSING, true, null)) {
for (final IProject project : projects.keySet()) {
// which can be handled
if (project != null && project.isAccessible() && projects.get(project) != null) {
final IResourceDelta projectDelta = projects.get(project);
final DeltaVisitor visitor = new DeltaVisitor();
try {
projectDelta.accept(visitor);
if (!visitor.hasNewOrRemovedResources() && (projectDelta.getFlags() & IResourceDelta.DESCRIPTION) == 0) {
continue;
}
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
final WorkspaceJob buildStarter = new WorkspaceJob("Build starter") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) {
GlobalDeltaVisitor tempVisitor = new GlobalDeltaVisitor(project);
try {
projectDelta.accept(tempVisitor);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
final WorkspaceJob[] outdatingJobs = tempVisitor.reportOutdatedFiles();
WorkspaceJob analyzeAfterOutdating = new WorkspaceJob("analyzeAfterOutdating") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
// Wait for reportOutdatedFiles() to finish
try {
for (WorkspaceJob job : outdatingJobs) {
if (job != null) {
job.join();
}
}
} catch (InterruptedException e) {
ErrorReporter.logExceptionStackTrace(e);
}
GlobalParser.getProjectSourceParser(project).analyzeAll(false);
if (ProjectBuildPropertyData.useAutomaticMakefilegeneration(project)) {
TITANBuilder.markProjectForRebuild(project);
TITANBuilder.regenerateMakefile(project);
}
return Status.OK_STATUS;
}
};
analyzeAfterOutdating.setPriority(Job.LONG);
analyzeAfterOutdating.setUser(false);
analyzeAfterOutdating.setSystem(true);
analyzeAfterOutdating.setProperty(IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor("titan.gif"));
analyzeAfterOutdating.schedule();
return Status.OK_STATUS;
}
};
buildStarter.setPriority(Job.LONG);
buildStarter.setUser(false);
buildStarter.setSystem(true);
buildStarter.setRule(project.getWorkspace().getRuleFactory().refreshRule(project));
buildStarter.setProperty(IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor("titan.gif"));
buildStarter.schedule();
}
}
}
}
Aggregations