Java Code Examples for org.eclipse.core.runtime.preferences.InstanceScope

The following are top voted examples for showing how to use org.eclipse.core.runtime.preferences.InstanceScope. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: n4js   File: OsgiBinariesPreferenceStore.java   Source Code and License 6 votes vote down vote up
@Override
public IStatus save() {
	try {
		final IEclipsePreferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
		for (final Entry<Binary, URI> entry : getOrCreateState().entrySet()) {
			final URI path = entry.getValue();
			if (null != path) {
				final File file = new File(path);
				if (file.isDirectory()) {
					node.put(entry.getKey().getId(), file.getAbsolutePath());
				}
			} else {
				// Set to default.
				node.put(entry.getKey().getId(), "");
			}
		}
		node.flush();
		return OK_STATUS;
	} catch (final BackingStoreException e) {
		final String message = "Unexpected error when trying to persist binary preferences.";
		LOGGER.error(message, e);
		return statusHelper.createError(message, e);
	}
}
 
Example 2
Project: Hydrograph   File: DebugDataViewer.java   Source Code and License 6 votes vote down vote up
/**
 * 
 * Get data viewer preferences from preference file
 * 
 * @return {@link ViewDataPreferencesVO}
 */
public ViewDataPreferencesVO getViewDataPreferencesFromPreferenceFile() {
	boolean includeHeaderValue = false;
	IEclipsePreferences eclipsePreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
	String delimiter = eclipsePreferences.get(DELIMITER, DEFAULT);
	String quoteCharactor = eclipsePreferences.get(QUOTE_CHARACTOR, DEFAULT);
	String includeHeader = eclipsePreferences.get(INCLUDE_HEADERS, DEFAULT);
	String fileSize = eclipsePreferences.get(FILE_SIZE, DEFAULT);
	String pageSize = eclipsePreferences.get(PAGE_SIZE, DEFAULT);
	delimiter = delimiter.equalsIgnoreCase(DEFAULT) ? DEFAULT_DELIMITER : delimiter;
	quoteCharactor = quoteCharactor.equalsIgnoreCase(DEFAULT) ? DEFAULT_QUOTE_CHARACTOR : quoteCharactor;
	includeHeaderValue = includeHeader.equalsIgnoreCase(DEFAULT) ? true : false;
	fileSize = fileSize.equalsIgnoreCase(DEFAULT) ? DEFAULT_FILE_SIZE : fileSize;
	pageSize = pageSize.equalsIgnoreCase(DEFAULT) ? DEFAULT_PAGE_SIZE : pageSize;
	ViewDataPreferencesVO viewDataPreferencesVO = new ViewDataPreferencesVO(delimiter, quoteCharactor,
			includeHeaderValue, Integer.parseInt(fileSize), Integer.parseInt(pageSize));
	return viewDataPreferencesVO;
}
 
Example 3
Project: termsuite-ui   File: LifeCycleManager.java   Source Code and License 6 votes vote down vote up
private void logContextualInfo() {
	Preferences preferences = InstanceScope.INSTANCE.getNode(TermSuiteUI.PLUGIN_ID);

	logger.info("Current directory: " + Paths.get(".").toAbsolutePath().normalize().toString());
	logger.info("Workspace location: " + Platform.getInstanceLocation().getURL().toString());
	logger.info("Output directory is " + preferences.get(TermSuiteUIPreferences.OUTPUT_DIRECTORY, ""));
	logger.info("Install location: " + Platform.getInstallLocation().getURL().toString());
	for(String p:LOGGED_PROPS)
		logger.info(p + ": " + System.getProperty(p));
	logger.info("eclipse.commands: " + System.getProperty("eclipse.commands").replaceAll("[\n\r]+", " "));
	logger.info("Command line args: " + Joiner.on(" ").join(Platform.getCommandLineArgs()));
	logger.info("Application args: " + Joiner.on(" ").join(Platform.getApplicationArgs()));
	
	BundleContext bundleContext = Platform.getBundle(TermSuiteUI.PLUGIN_ID).getBundleContext();
	
	for(Bundle bundle:bundleContext.getBundles()) {
		if(bundle.getSymbolicName().startsWith("fr.univnantes.termsuite"))
			logger.info("Found bundle " +bundle.getSymbolicName() + ":" + bundle.getVersion());
	}
}
 
Example 4
Project: termsuite-ui   File: AlignmentServiceImpl.java   Source Code and License 6 votes vote down vote up
@PostConstruct
private void loadDictionaries() {
	targetDictionaries = HashMultimap.create();
	sourceDictionaries = HashMultimap.create();
	
	Preferences preferences = InstanceScope.INSTANCE
			  .getNode(TermSuiteUI.PLUGIN_ID);

	String dictionaryDirectory = preferences.get(TermSuiteUIPreferences.BILINGUAL_DICTIONARY_DIRECTORY, null);
	
	dictionaries = dictionaryDirectory == null ? 
			Lists.newArrayList() : 
				findDictionaries(Paths.get(dictionaryDirectory));
		
	for(EBilingualDictionary dico:dictionaries) {
		sourceDictionaries.put(dico.getSourceLang(), dico);
		targetDictionaries.put(dico.getTargetLang(), dico);
	}
}
 
Example 5
Project: tm4e   File: ThemeManager.java   Source Code and License 6 votes vote down vote up
/**
 * Load TextMate Themes from preferences.
 */
private void loadThemesFromPreferences() {
	// Load Theme definitions from the
	// "${workspace_loc}/metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.tm4e.ui.prefs"
	IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(TMUIPlugin.PLUGIN_ID);
	String json = prefs.get(PreferenceConstants.THEMES, null);
	if (json != null) {
		ITheme[] themes = PreferenceHelper.loadThemes(json);
		for (ITheme theme : themes) {
			super.registerTheme(theme);
		}
	}

	json = prefs.get(PreferenceConstants.THEME_ASSOCIATIONS, null);
	if (json != null) {
		IThemeAssociation[] themeAssociations = PreferenceHelper.loadThemeAssociations(json);
		for (IThemeAssociation association : themeAssociations) {
			super.registerThemeAssociation(association);
		}
	}
}
 
Example 6
Project: tm4e   File: ThemeManager.java   Source Code and License 6 votes vote down vote up
@Override
public void save() throws BackingStoreException {
	// Save Themes in the
	// "${workspace_loc}/metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.tm4e.ui.prefs"
	String json = PreferenceHelper.toJsonThemes(
			Arrays.stream(getThemes()).filter(t -> t.getPluginId() == null).collect(Collectors.toList()));
	IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(TMUIPlugin.PLUGIN_ID);
	prefs.put(PreferenceConstants.THEMES, json);

	// Save Theme associations in the
	// "${workspace_loc}/metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.tm4e.ui.prefs"
	json = PreferenceHelper.toJsonThemeAssociations(Arrays.stream(getAllThemeAssociations())
			.filter(t -> t.getPluginId() == null).collect(Collectors.toList()));
	prefs.put(PreferenceConstants.THEME_ASSOCIATIONS, json);

	// Save preferences
	prefs.flush();
}
 
Example 7
Project: team-explorer-everywhere   File: SynchronizeLabelDecorator.java   Source Code and License 6 votes vote down vote up
public SynchronizeLabelDecorator(final Subscriber subscriber) {
    this.subscriber = subscriber;

    preferenceStore = new ScopedPreferenceStore(new InstanceScope(), TEAM_UI_PLUGIN_ID);

    decorate = Boolean.TRUE.equals(preferenceStore.getBoolean(DECORATION_PREFERENCE_CONSTANT));

    preferenceStore.addPropertyChangeListener(new IPropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            if (event.getProperty().equals(DECORATION_PREFERENCE_CONSTANT)) {
                /*
                 * Note that we compare against the string value of the
                 * preference here. Preferences are not strongly typed
                 * (they're strings under the hood), so in the property
                 * change event, we're given the string value.
                 */
                decorate = "true".equals(event.getNewValue()); //$NON-NLS-1$

                ((ILabelProviderListener) listeners.getListener()).labelProviderChanged(
                    new LabelProviderChangedEvent(SynchronizeLabelDecorator.this));
            }
        }
    });
}
 
Example 8
Project: Notepad4e   File: Note.java   Source Code and License 6 votes vote down vote up
/**
 * Constructor. Sets properties of the editor window.
 * 
 * @param parent
 * @param text
 * @param editable
 * @param shortcutHandler
 */
public Note(Composite parent, String text, boolean editable) {
	// Enable multiple lines and scroll bars.
	super(parent, SWT.V_SCROLL | SWT.H_SCROLL);

	preferences = InstanceScope.INSTANCE.getNode(Notepad4e.PLUGIN_ID);

	undoRedoManager = new UndoRedoManager(this);
	bulletStyle = new StyleRange();
	bulletStyle.metrics = new GlyphMetrics(0, 0, 0);

	// Scroll bars only appear when the text extends beyond the note window.
	setAlwaysShowScrollBars(false);
	setParametersFromPreferences();
	setText(text);
	initialiseMenu();

	if (!editable) {
		toggleEditable();
	}
}
 
Example 9
Project: hybris-commerce-eclipse-plugin   File: Activator.java   Source Code and License 6 votes vote down vote up
public void start(BundleContext context) throws Exception {
	super.start(context);
	plugin = this;
	String platformHomeStr = null;
	if (platformHome == null) {

		Preferences preferences = InstanceScope.INSTANCE.getNode("com.hybris.hyeclipse.preferences");
		platformHomeStr = preferences.get("platform_home", null);
		if (platformHomeStr == null) {
			IProject platformProject = ResourcesPlugin.getWorkspace().getRoot().getProject("platform");
			IPath platformProjectPath = platformProject.getLocation();
			if (platformProjectPath != null) {
				platformHome = platformProjectPath.toFile();
				platformHomeStr = platformHome.getAbsolutePath();
			}
		} else {
			platformHome = new File(platformHomeStr);
		}
	}
}
 
Example 10
Project: hybris-commerce-eclipse-plugin   File: Activator.java   Source Code and License 6 votes vote down vote up
public File getPlatformHome() {
	if (platformHome == null) {
		
		//Get platform home from workspace preferences
		Preferences preferences = InstanceScope.INSTANCE.getNode("com.hybris.hyeclipse.preferences");
		String platformHomeStr = preferences.get("platform_home", null);
		if (platformHomeStr == null) {
			IProject platformProject = ResourcesPlugin.getWorkspace().getRoot().getProject("platform");
			IPath platformProjectPath = platformProject.getLocation();
			if (platformProjectPath != null) {
				setPlatformHome(platformProjectPath.toFile());
			}
		}
		else {
			setPlatformHome(new File(platformHomeStr));
		}
	}
	return platformHome;
}
 
Example 11
Project: hybris-commerce-eclipse-plugin   File: PlatformHomePropertyTester.java   Source Code and License 6 votes vote down vote up
@Override
public boolean test(Object arg0, String arg1, Object[] arg2, Object arg3) {
	
	boolean enableOption = false;
	Preferences preferences = InstanceScope.INSTANCE.getNode("com.hybris.hyeclipse.preferences");
	String platformHomeStr = preferences.get("platform_home", null);
	if (platformHomeStr == null) {
		IProject platformProject = ResourcesPlugin.getWorkspace().getRoot().getProject("platform");
		IPath platformProjectPath = platformProject.getLocation();
		if (platformProjectPath != null) {
			enableOption = true;
		}
	}
	else {
		enableOption = true;
	}
	
	return enableOption;
}
 
Example 12
Project: hybris-commerce-eclipse-plugin   File: CommandState.java   Source Code and License 6 votes vote down vote up
@Override
public Map<String, String> getCurrentState() {
	Map<String, String> map = new HashMap<String, String>(1);
	boolean enableOption = false;
	Preferences preferences = InstanceScope.INSTANCE.getNode("com.hybris.hyeclipse.preferences");
	String platformHomeStr = preferences.get("platform_home", null);
	if (platformHomeStr == null) {
		IProject platformProject = ResourcesPlugin.getWorkspace().getRoot().getProject("platform");
		IPath platformProjectPath = platformProject.getLocation();
		if (platformProjectPath != null) {
			enableOption = true;
		}
	}
	else {
		enableOption = true;
	}
	
	if (enableOption) {
		map.put(ID, ENABLED);
	}
	else {
		map.put(ID, DISABLED);
	}
	return map;
}
 
Example 13
Project: hybris-commerce-eclipse-plugin   File: Activator.java   Source Code and License 6 votes vote down vote up
public void start(BundleContext context) throws Exception {
	super.start(context);
	plugin = this;
	String platformHomeStr = null;
	if (platformHome == null) {
		
		Preferences preferences = InstanceScope.INSTANCE.getNode("com.hybris.hyeclipse.preferences");
		platformHomeStr = preferences.get("platform_home", null);
		if (platformHomeStr == null) {
			IProject platformProject = ResourcesPlugin.getWorkspace().getRoot().getProject("platform");
			IPath platformProjectPath = platformProject.getLocation();
			if (platformProjectPath != null) {
				platformHome = platformProjectPath.toFile();
			}
		}
		else {
			platformHome = new File(platformHomeStr);
		}
	}
	
	disableProjectNatureSolutionLookup();
	log("Disabled automatic project nature solution lookup");
}
 
Example 14
Project: hybris-commerce-eclipse-plugin   File: Activator.java   Source Code and License 6 votes vote down vote up
public void resetPlatform(String platformHome) {
	
	try {
		Preferences preferences = InstanceScope.INSTANCE.getNode("com.hybris.hyeclipse.preferences");
		preferences.put("platform_home", platformHome);
		preferences.flush();
	}
	catch (BackingStoreException e) {
		logError("Failed to persist platform_home", e);
	}
	
	getTypeSystemExporter().setPlatformHome(null);
	getTypeSystemExporter().nullifySystemConfig();
	getTypeSystemExporter().nullifyPlatformConfig();
	getTypeSystemExporter().nullifyTypeSystem();
	getTypeSystemExporter().nullifyAllTypes();
	getTypeSystemExporter().nullifyAllTypeNames();
}
 
Example 15
Project: hybris-commerce-eclipse-plugin   File: Activator.java   Source Code and License 6 votes vote down vote up
@Override
public void start(BundleContext context) throws Exception {
	super.start(context);
	plugin = this;
	String platformHomeStr = null;
	if (platformHome == null) {
		
		Preferences preferences = InstanceScope.INSTANCE.getNode("com.hybris.hyeclipse.preferences");
		platformHomeStr = preferences.get("platform_home", null);
		if (platformHomeStr == null) {
			IProject platformProject = ResourcesPlugin.getWorkspace().getRoot().getProject("platform");
			IPath platformProjectPath = platformProject.getLocation();
			if (platformProjectPath != null) {
				platformHome = platformProjectPath.toFile();
				platformHomeStr = platformHome.getAbsolutePath();
			}
		}
		else {
			platformHome = new File(platformHomeStr);
		}
	}
}
 
Example 16
Project: cft   File: StsTestUtil.java   Source Code and License 6 votes vote down vote up
/**
 * Set a bunch of preferences so that m2eclipse hopefully isn't doing a lot
 * of time consuming stuff in the background.
 */
public static void mavenOffline() throws Error {
	System.out.println("Pacifying m2eclipse...");
	IEclipsePreferences m2EclipsePrefs = new InstanceScope().getNode("org.eclipse.m2e.core");
	m2EclipsePrefs.putBoolean("eclipse.m2.offline", true);
	m2EclipsePrefs.putBoolean("eclipse.m2.globalUpdatePolicy", false);
	m2EclipsePrefs.putBoolean("eclipse.m2.updateIndexes", false);
	try {
		m2EclipsePrefs.flush();
	}
	catch (BackingStoreException e) {
		throw new Error(e);
	}

	// LegacyProjectChecker.NON_BLOCKING = true;
	System.out.println("Pacifying m2eclipse...DONE");
}
 
Example 17
Project: cft   File: ModuleCache.java   Source Code and License 6 votes vote down vote up
private void setLocalModuleToCloudModuleMapping(Map<String, String> list) {
	String string = convertMapToString(list);
	IEclipsePreferences node = new InstanceScope().getNode(CloudFoundryPlugin.PLUGIN_ID);
	CloudFoundryPlugin.trace("Updated mapping: " + string); //$NON-NLS-1$
	node.put(KEY_MODULE_MAPPING_LIST + ":" + getServerId(), string); //$NON-NLS-1$
	try {
		node.flush();
	}
	catch (BackingStoreException e) {
		CloudFoundryPlugin
				.getDefault()
				.getLog()
				.log(new Status(IStatus.ERROR, CloudFoundryPlugin.PLUGIN_ID,
						"Failed to update application mappings", e)); //$NON-NLS-1$
	}
}
 
Example 18
Project: cft   File: ModuleCache.java   Source Code and License 6 votes vote down vote up
protected synchronized void remove(IServer server) {
	dataByServer.remove(server);

	CloudFoundryServer cfs =  (CloudFoundryServer)server.loadAdapter(CloudFoundryServer.class, null);
	
	String serverId =  cfs.getServerId(); 
	
	if (serverId != null) {
		IEclipsePreferences node = new InstanceScope().getNode(CloudFoundryPlugin.PLUGIN_ID);
		node.remove(KEY_MODULE_MAPPING_LIST + ":" + serverId); //$NON-NLS-1$
		try {
			node.flush();
		}
		catch (BackingStoreException e) {
			CloudFoundryPlugin
					.getDefault()
					.getLog()
					.log(new Status(IStatus.ERROR, CloudFoundryPlugin.PLUGIN_ID,
							"Failed to remove application mappings", e)); //$NON-NLS-1$
		}
	}
}
 
Example 19
Project: bts   File: BTSEObjectHover.java   Source Code and License 6 votes vote down vote up
public IInformationControlCreatorProvider getHoverInfo(final EObject object, final ITextViewer viewer, final IRegion region)
{
	boolean showHover = true;
	try {
		IEclipsePreferences defaultNode = DefaultScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus.egy");
		IEclipsePreferences instanceNode = InstanceScope.INSTANCE.getNode("org.bbaw.bts.ui.corpus.egy");
		showHover = instanceNode.getBoolean(BTSEGYUIConstants.PREF_TRANSLITERATION_EDITOR_ACTIVATE_HOVER_INFO, 
			defaultNode.getBoolean(BTSEGYUIConstants.PREF_TRANSLITERATION_EDITOR_ACTIVATE_HOVER_INFO, true));
	} catch (Exception e) {
	}
	if (showHover)
	{
		return super.getHoverInfo(object, viewer, region);
	}
	return null;
	
}
 
Example 20
Project: bts   File: PreferenceStoreAccessImpl.java   Source Code and License 6 votes vote down vote up
@SuppressWarnings("deprecation")
public IPreferenceStore getWritablePreferenceStore(Object context) {
	lazyInitialize();
	if (context instanceof IFileEditorInput) {
		context = ((IFileEditorInput) context).getFile().getProject();
	}
	if (context instanceof IProject) {
		ProjectScope projectScope = new ProjectScope((IProject) context);
		FixedScopedPreferenceStore result = new FixedScopedPreferenceStore(projectScope, getQualifier());
		result.setSearchContexts(new IScopeContext[] {
			projectScope,
			new InstanceScope(),
			new ConfigurationScope()
		});
		return result;
	}
	return getWritablePreferenceStore();
}
 
Example 21
Project: bts   File: ConfigurationPage.java   Source Code and License 6 votes vote down vote up
/**
 * Create contents of the preference page.
 */
@Override
protected void createFieldEditors() {
	// Create the field editors
	IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.bbaw.bts.app");
	Composite container = (Composite) this.getControl();
	container.setLayout(new GridLayout(1, false));

	Label activeConfigLB = new Label(container, SWT.NONE);
	activeConfigLB.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false,
			false, 1, 1));
	activeConfigLB.setText("Currently active Configuration");

	activeConfigcomboViewer = new ComboViewer(container, SWT.READ_ONLY);
	activeConfigcomboViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
			false, 1, 1));
	ComposedAdapterFactory factory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
	AdapterFactoryLabelProvider labelProvider = new AdapterFactoryLabelProvider(factory);
	activeConfigcomboViewer.setContentProvider(new AdapterFactoryContentProvider(factory));
	activeConfigcomboViewer.setLabelProvider(labelProvider);		
	
	
	init(null);
	loaded = true;
}
 
Example 22
Project: bts   File: LoginRememberMePage.java   Source Code and License 6 votes vote down vote up
/**
	 * Create contents of the preference page.
	 */
	@Override
	protected void createFieldEditors() {
		// Create the field editors
		IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.bbaw.bts.app");
		

//		addField(new BooleanFieldEditor("remember_me", "Remember my login credentials on startup", BooleanFieldEditor.DEFAULT, getFieldEditorParent()));
		Composite container = (Composite) this.getControl();
		container.setLayout(new GridLayout(1, false));
		Label lblNewLabel = new Label(container, SWT.NONE);
		lblNewLabel.setText("Login Preferences");
		
		btnCheckButton = new Button(container, SWT.CHECK);
		btnCheckButton.setText("Remember my login credentials on startup");
		
		init(null);
		loaded = true;
	}
 
Example 23
Project: jsweet-eclipse-plugin   File: JSweetBuilder.java   Source Code and License 6 votes vote down vote up
private void forceStaticImports() {
	try {
		IPreferenceStore s = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.jdt.ui");
		String favorites = s.getString(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS);
		for (String f : defaultFavorites) {
			if (!favorites.contains(f)) {
				if (!favorites.isEmpty()) {
					favorites += ";";
				}
				favorites += f;
			}
		}
		Log.info("forcing favorite static members: " + favorites);
		s.setValue(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS, favorites);
	} catch (Exception e) {
		Log.error(e);
	}
}
 
Example 24
Project: dockerfoundry   File: ModuleCache.java   Source Code and License 6 votes vote down vote up
private void setLocalModuleToCloudModuleMapping(Map<String, String> list) {
	String string = convertMapToString(list);
	IEclipsePreferences node = new InstanceScope().getNode(DockerFoundryPlugin.PLUGIN_ID);
	DockerFoundryPlugin.trace("Updated mapping: " + string); //$NON-NLS-1$
	node.put(KEY_MODULE_MAPPING_LIST + ":" + getServerId(), string); //$NON-NLS-1$
	try {
		node.flush();
	}
	catch (BackingStoreException e) {
		DockerFoundryPlugin
				.getDefault()
				.getLog()
				.log(new Status(IStatus.ERROR, DockerFoundryPlugin.PLUGIN_ID,
						"Failed to update application mappings", e)); //$NON-NLS-1$
	}
}
 
Example 25
Project: dockerfoundry   File: ModuleCache.java   Source Code and License 6 votes vote down vote up
protected synchronized void remove(IServer server) {
	dataByServer.remove(server);

	String serverId = server.getAttribute(DockerFoundryServer.PROP_SERVER_ID, (String) null);
	if (serverId != null) {
		IEclipsePreferences node = new InstanceScope().getNode(DockerFoundryPlugin.PLUGIN_ID);
		node.remove(KEY_MODULE_MAPPING_LIST + ":" + serverId); //$NON-NLS-1$
		try {
			node.flush();
		}
		catch (BackingStoreException e) {
			DockerFoundryPlugin
					.getDefault()
					.getLog()
					.log(new Status(IStatus.ERROR, DockerFoundryPlugin.PLUGIN_ID,
							"Failed to remove application mappings", e)); //$NON-NLS-1$
		}
	}
}
 
Example 26
Project: ModularityCheck   File: ModularityCheck.java   Source Code and License 6 votes vote down vote up
/**
 * Load the parameters to run ModularityCheck.
 */
public void loadPreferences() {
	@SuppressWarnings("deprecation")
	Preferences preferences = new InstanceScope().getNode(PLUGIN_ID);
	try {
		repoType = preferences.getInt(REPO_TYPE, 0);
		repoManager = preferences.getInt(REPO_MANAGER, 0);
		repoUrl = preferences.get(REPO_URL, " ");
		repoXml = preferences.get(REPO_XML, " ");
		repoBegin = new SimpleDateFormat("yyyy-MM-dd").parse(preferences
				.get(REPO_BEGIN, (new Date()).toString()));
		repoEnd = new SimpleDateFormat("yyyy-MM-dd").parse(preferences.get(
				REPO_END, (new Date()).toString()));
		lastExec = preferences.get(LAST_EXEC_PARAMS, " ");
	} catch (ParseException e) {
		ConfigurationsDialog cd = new ConfigurationsDialog();
		cd.showDialog(Display.getDefault().getActiveShell());
	}
}
 
Example 27
Project: ModularityCheck   File: ModularityCheck.java   Source Code and License 6 votes vote down vote up
/**
 * Load the parameters to run ModularityCheck.
 */
private void loadPreferences() {
	@SuppressWarnings("deprecation")
	Preferences preferences = new InstanceScope().getNode(PLUGIN_ID);
	try {
		contents.setRepoType(preferences.getInt(REPO_TYPE, 0));
		contents.setRepoManager(preferences.getInt(REPO_MANAGER, 0));
		contents.setRepoUrl(preferences.get(REPO_URL, " "));
		contents.setRepoXml(preferences.get(REPO_XML, " ")); 
		contents.setRepoBegin(new SimpleDateFormat("yyyy-MM-dd").parse(preferences
				.get(REPO_BEGIN, (new Date()).toString())));
		contents.setRepoEnd(new SimpleDateFormat("yyyy-MM-dd").parse(preferences.get(
				REPO_END, (new Date()).toString())));
		contents.setLastExec(preferences.get(LAST_EXEC_PARAMS, " "));
		
		} catch (ParseException e) {
			ConfigurationsDialog cd = new ConfigurationsDialog();
			cd.showDialog(Display.getDefault().getActiveShell());
		}
}
 
Example 28
Project: ModularityCheck   File: GITManager.java   Source Code and License 6 votes vote down vote up
private void cloneRepository() throws IOException, InvalidRemoteException, TransportException, GitAPIException {
	File localPath = File.createTempFile("TestGitRepository", "");
       localPath.delete();
       
       System.out.println("Cloning from " + repository_url + " to " + localPath);
       Git result = Git.cloneRepository()
               .setURI(repository_url)
               .setDirectory(localPath)
               .call();

       
        // Note: the call() returns an opened repository already which needs to be closed to avoid file handle leaks!
        System.out.println("Having repository: " + result.getRepository().getDirectory());
       
        repositoryPath = result.getRepository().getDirectory().getAbsolutePath();
        
        @SuppressWarnings("deprecation")
		Preferences preferences = new InstanceScope().getNode(ModularityCheck.PLUGIN_ID);
		preferences.put(REPOSITORY_PATH, repositoryPath);
}
 
Example 29
Project: e4-cookbook-migration-guide   File: ContributedPreferenceNode.java   Source Code and License 6 votes vote down vote up
@Override
public void createPage() {
	try {
		setPage(this.pageClass.newInstance());
	} catch (InstantiationException|IllegalAccessException e) {
		e.printStackTrace();
	}
	
	if (getLabelImage() != null) {
		getPage().setImageDescriptor(getImageDescriptor());
	}
       getPage().setTitle(getLabelText());
       
       ((PreferencePage)getPage()).setPreferenceStore(
       		new ScopedPreferenceStore(InstanceScope.INSTANCE, this.nodeQualifier));
}
 
Example 30
Project: che   File: StubUtility.java   Source Code and License 6 votes vote down vote up
public static String getLineDelimiterPreference(IProject project) {
  IScopeContext[] scopeContext;
  if (project != null) {
    // project preference
    scopeContext = new IScopeContext[] {new ProjectScope(project)};
    String lineDelimiter =
        Platform.getPreferencesService()
            .getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
    if (lineDelimiter != null) return lineDelimiter;
  }
  // workspace preference
  scopeContext = new IScopeContext[] {InstanceScope.INSTANCE};
  String platformDefault =
      System.getProperty("line.separator", "\n"); // $NON-NLS-1$ //$NON-NLS-2$
  return Platform.getPreferencesService()
      .getString(
          Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, platformDefault, scopeContext);
}
 
Example 31
Project: eclox   File: Doxygen.java   Source Code and License 6 votes vote down vote up
/**
 * Retrieves the default doxygen instance to use.
 */
public static Doxygen getDefault() {
    Doxygen doxygen = null;
    // get the actual default preference store
    //final String identifier  = Plugin.getDefault().getPluginPreferences().getString( IPreferences.DEFAULT_DOXYGEN );
    IPreferencesService service = Platform.getPreferencesService();
    final String PLUGIN_ID = Plugin.getDefault().getBundle().getSymbolicName();
    IEclipsePreferences defaultNode = DefaultScope.INSTANCE.getNode(PLUGIN_ID);
    IEclipsePreferences instanceNode = InstanceScope.INSTANCE.getNode(PLUGIN_ID);
    IEclipsePreferences[] nodes = new IEclipsePreferences[] { instanceNode, defaultNode };
    final String identifier = service.get(IPreferences.DEFAULT_DOXYGEN, "", nodes);

    List<Class<? extends Doxygen>> doxygenClassList = new ArrayList<Class<? extends Doxygen>>();
    doxygenClassList.add(DefaultDoxygen.class);
    doxygenClassList.add(CustomDoxygen.class);
    doxygenClassList.add(BundledDoxygen.class);
    for (Class<? extends Doxygen> doxygenClass : doxygenClassList) {
        doxygen = getFromClassAndIdentifier(doxygenClass, identifier);
        if (doxygen != null)
            break;
    }
    return doxygen;
}
 
Example 32
Project: org.csstudio.display.builder   File: Activator.java   Source Code and License 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public void start(BundleContext context) throws Exception
{
    super.start(context);
    if (SingleSourcePlugin.getUIHelper().getUI() == UI.RAP)
    {
        // Is this necessary?
        // RAPCorePlugin adds the "server" scope for all plugins,
        // but starts too late...
        Platform.getPreferencesService().setDefaultLookupOrder(
                PLUGIN_ID, null,
                new String[]
                        {
                                InstanceScope.SCOPE,
                                ConfigurationScope.SCOPE,
                                "server",
                                DefaultScope.SCOPE
                        });
    }
    plugin = this;
}
 
Example 33
Project: gwt-eclipse-plugin   File: InlinedCssFormattingStrategy.java   Source Code and License 6 votes vote down vote up
private String computeOneXmlIndentString() {
  char indentChar = ' ';
  IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(XMLCorePlugin.DEFAULT_CATALOG_ID);
  String indentCharPref = prefs.get(XMLCorePreferenceNames.INDENTATION_CHAR, null);

  if (XMLCorePreferenceNames.TAB.equals(indentCharPref)) {
    indentChar = '\t';
  }
  int indentationWidth = prefs.getInt(XMLCorePreferenceNames.INDENTATION_SIZE, 0);

  StringBuilder indent = new StringBuilder();
  for (int i = 0; i < indentationWidth; i++) {
    indent.append(indentChar);
  }
  return indent.toString();
}
 
Example 34
Project: gama   File: WorkspacePreferences.java   Source Code and License 6 votes vote down vote up
public static IPreferenceFilter[] getPreferenceFilters() {
	final IPreferenceFilter[] transfers = new IPreferenceFilter[1];

	// For export all create a preference filter that can export
	// all nodes of the Instance and Configuration scopes
	transfers[0] = new IPreferenceFilter() {

		@Override
		public String[] getScopes() {
			return new String[] { InstanceScope.SCOPE };
		}

		@Override
		public Map getMapping(final String scope) {
			return null;
		}
	};

	return transfers;
}
 
Example 35
Project: eclipse-wtp-json   File: Validator.java   Source Code and License 6 votes vote down vote up
protected IScopeContext[] createPreferenceScopes(
		NestedValidatorContext context) {
	if (context != null) {
		final IProject project = context.getProject();
		if (project != null && project.isAccessible()) {
			final ProjectScope projectScope = new ProjectScope(project);
			if (projectScope.getNode(
					JSONCorePlugin.getDefault().getBundle()
							.getSymbolicName()).getBoolean(
					JSONCorePreferenceNames.USE_PROJECT_SETTINGS, false))
				return new IScopeContext[] { projectScope,
						new InstanceScope(), new DefaultScope() };
		}
	}
	return new IScopeContext[] { new InstanceScope(), new DefaultScope() };
}
 
Example 36
Project: Eclipse-Postfix-Code-Completion   File: CleanUpPreferenceUtil.java   Source Code and License 6 votes vote down vote up
public static Map<String, String> loadSaveParticipantOptions(IScopeContext context) {
	IEclipsePreferences node;
	if (hasSettingsInScope(context)) {
		node= context.getNode(JavaUI.ID_PLUGIN);
	} else {
		IScopeContext instanceScope= InstanceScope.INSTANCE;
		if (hasSettingsInScope(instanceScope)) {
			node= instanceScope.getNode(JavaUI.ID_PLUGIN);
		} else {
			return JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getMap();
		}
	}

	Map<String, String> result= new HashMap<String, String>();
	Set<String> keys= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getKeys();
	for (Iterator<String> iterator= keys.iterator(); iterator.hasNext();) {
        String key= iterator.next();
        result.put(key, node.get(SAVE_PARTICIPANT_KEY_PREFIX + key, CleanUpOptions.FALSE));
       }

	return result;
}
 
Example 37
Project: Eclipse-Postfix-Code-Completion   File: ProfileManager.java   Source Code and License 6 votes vote down vote up
/**
 * Update all formatter settings with the settings of the specified profile.
 * @param profile The profile to write to the preference store
 */
private void writeToPreferenceStore(Profile profile, IScopeContext context) {
	final Map<String, String> profileOptions= profile.getSettings();

	for (int i= 0; i < fKeySets.length; i++) {
        updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), profileOptions);
       }

	final IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN);
	if (uiPrefs.getInt(fProfileVersionKey, 0) != fProfileVersioner.getCurrentVersion()) {
		uiPrefs.putInt(fProfileVersionKey, fProfileVersioner.getCurrentVersion());
	}

	if (context.getName() == InstanceScope.SCOPE) {
		uiPrefs.put(fProfileKey, profile.getID());
	} else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) {
		uiPrefs.put(fProfileKey, profile.getID());
	}
}
 
Example 38
Project: Eclipse-Postfix-Code-Completion   File: CleanUpSaveParticipantPreferenceConfiguration.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performDefaults() {
	if (ProjectScope.SCOPE.equals(fContext.getName()) && !hasSettingsInScope(fContext))
		return;

	enabled(true);

	if (ProjectScope.SCOPE.equals(fContext.getName())) {
		fSettings= CleanUpPreferenceUtil.loadSaveParticipantOptions(InstanceScope.INSTANCE);
	} else {
		fSettings= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getMap();
	}
	settingsChanged();

	super.performDefaults();
}
 
Example 39
Project: Eclipse-Postfix-Code-Completion   File: CleanUpRefactoringWizard.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public String getColumnText(Object element, int columnIndex) {
	if (columnIndex == 0) {
		return ((IJavaProject)element).getProject().getName();
	} else if (columnIndex == 1) {

		if (fProfileIdsTable == null)
    		fProfileIdsTable= loadProfiles();

		IEclipsePreferences instancePreferences= InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN);

   		final String workbenchProfileId;
   		if (instancePreferences.get(CleanUpConstants.CLEANUP_PROFILE, null) != null) {
   			workbenchProfileId= instancePreferences.get(CleanUpConstants.CLEANUP_PROFILE, null);
   		} else {
   			workbenchProfileId= CleanUpConstants.DEFAULT_PROFILE;
   		}

		return getProjectProfileName((IJavaProject)element, fProfileIdsTable, workbenchProfileId);
	}
	return null;
}
 
Example 40
Project: Eclipse-Postfix-Code-Completion   File: JavaCorePreferenceModifyListener.java   Source Code and License 6 votes vote down vote up
public IEclipsePreferences preApply(IEclipsePreferences node) {
	// the node does not need to be the root of the hierarchy
	Preferences root = node.node("/"); //$NON-NLS-1$
	try {
		// we must not create empty preference nodes, so first check if the node exists
		if (root.nodeExists(InstanceScope.SCOPE)) {
			Preferences instance = root.node(InstanceScope.SCOPE);
			// we must not create empty preference nodes, so first check if the node exists
			if (instance.nodeExists(JavaCore.PLUGIN_ID)) {
				cleanJavaCore(instance.node(JavaCore.PLUGIN_ID));
			}
		}
	} catch (BackingStoreException e) {
		// do nothing
	}
	return super.preApply(node);
}
 
Example 41
Project: parichayana   File: ParichayanaActivator.java   Source Code and License 6 votes vote down vote up
public static String getPreference(String name, String defaultValue, IProject project) {
	IEclipsePreferences[] preferencesLookup;
	if (project != null) {
		preferencesLookup = new IEclipsePreferences[] {
				new ProjectScope(project).getNode(PLUGIN_ID),
				InstanceScope.INSTANCE.getNode(PLUGIN_ID),
				DefaultScope.INSTANCE.getNode(PLUGIN_ID)
		};
	} else {
		preferencesLookup = new IEclipsePreferences[] {
				InstanceScope.INSTANCE.getNode(PLUGIN_ID),
				DefaultScope.INSTANCE.getNode(PLUGIN_ID)
		};
	}
	IPreferencesService service = Platform.getPreferencesService();
	String value = service.get(name, defaultValue, preferencesLookup);
	return value;
}
 
Example 42
Project: developer-studio   File: WSO2PluginListSelectionPage.java   Source Code and License 6 votes vote down vote up
private boolean updateSampleTemplates() {
	IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(PreferenceInitializer.PREFERENCES_PLUGIN_ID);
	String value = prefs.get(DeveloperPreferencePage.PLUGIN_TEMPLATE_URL, PreferenceInitializer.KERNEL_SAMPLES_GIT);
	if (value == null || value.isEmpty()) {
		value = PreferenceInitializer.KERNEL_SAMPLES_GIT;
	}
	String gitRepoURL = value;
	File yourTempFile = new File(tempCloneDir);
	try {
		if (!yourTempFile.exists()) {
			yourTempFile.mkdir();
			JGitSampleRepoManager.gitClone(gitRepoURL, tempCloneDir);
			return true;
		} else {
			JGitSampleRepoManager.gitPull(tempCloneDir);
			return true;
		}
	} catch (GitAPIException | IOException e) {
		log.error("could not clone content from the git URL " + gitRepoURL + e);
	}
	return false;
}
 
Example 43
Project: thym   File: WPCore.java   Source Code and License 6 votes vote down vote up
/**
 * Get path to Windows Phone SDK root folder.
 * 
 * @return path to Windows Phone SDK root folder or <code>null</code> if SDK
 *         cannot be retrieved from preferences or detected from Windows
 *         registry (or running system is not Windows).
 * @throws CoreException 
 */
public static String getSDKLocation() throws CoreException {
	if(!System.getProperty("os.name").toLowerCase().startsWith("win")) {
		return null;
	}
	String sdkLocation = Platform.getPreferencesService().getString(
			THYM_UI_ID, WPConstants.WINDOWS_PHONE_SDK_LOCATION_PREF, null,
			null);
	if (sdkLocation == null) {
		File location = detectSDK();
		if (location != null && location.exists()) {
			sdkLocation = location.getAbsolutePath();
			IEclipsePreferences prefs = InstanceScope.INSTANCE
					.getNode(THYM_UI_ID);
			prefs.put(WPConstants.WINDOWS_PHONE_SDK_LOCATION_PREF,
					sdkLocation);
		}
	}
	return sdkLocation;
}
 
Example 44
Project: eclipse-wtp-webresources   File: PreferencesWebResourcesProvider.java   Source Code and License 6 votes vote down vote up
private boolean isSearchInAllCSSFiles(IProject project) {
	if (fPreferenceService == null) {
		fPreferenceService = Platform.getPreferencesService();
	}

	IScopeContext[] fLookupOrder;
	ProjectScope projectScope = new ProjectScope(project);
	if (projectScope
			.getNode(getQualifier())
			.getBoolean(
					WebResourcesCorePreferenceNames.CSS_USE_PROJECT_SETTINGS,
					false)) {
		fLookupOrder = new IScopeContext[] { projectScope,
				new InstanceScope(), new DefaultScope() };
	} else {
		fLookupOrder = new IScopeContext[] { new InstanceScope(),
				new DefaultScope() };
	}
	return fPreferenceService
			.getBoolean(
					getQualifier(),
					WebResourcesCorePreferenceNames.SEARCH_IN_ALL_CSS_FILES_IF_NO_LINKS,
					false, fLookupOrder);
}
 
Example 45
Project: wt-studio   File: LineEndingUtil.java   Source Code and License 6 votes vote down vote up
public static String determineProjectLineEnding(IFile file) {
	String lineEnding = null;
	if (file != null && file.getProject() != null) {
		lineEnding = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, new IScopeContext[] { new ProjectScope(file.getProject()) });
	}

	if (lineEnding == null) {
		lineEnding = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, new IScopeContext[] {
				InstanceScope.INSTANCE});
	}

	if (lineEnding == null) {
		lineEnding = System.getProperty(Platform.PREF_LINE_SEPARATOR);
	}

	return lineEnding;
}
 
Example 46
Project: SPLevo   File: JaMoPPTodoTagCustomizer.java   Source Code and License 6 votes vote down vote up
@Override
public void adjustTodoTags() {
    ScopedPreferenceStore jdt = new ScopedPreferenceStore(InstanceScope.INSTANCE, JDT_PROPERTIES_QUALIFIER);
    
    String taskTags = jdt.getString(TODO_TASK_TAG_PROPERTY_QUALIFIER);
    if (taskTags.contains(TODO_TASK_TAG)) {
        return;
    }
    taskTags = taskTags + "," + TODO_TASK_TAG;
    jdt.putValue(TODO_TASK_TAG_PROPERTY_QUALIFIER, taskTags);
    
    String taskPriorities = jdt.getString(TODO_TASK_PRIORITY_PROPERTY_QUALIFIER);
    taskPriorities = taskPriorities + "," + TODO_TASK_PRIORITY;
    jdt.putValue(TODO_TASK_PRIORITY_PROPERTY_QUALIFIER, taskPriorities);
    
    try {
        jdt.save();
    } catch (IOException e) {
        LOGGER.warn("Could not save preferences.", e);
    }
}
 
Example 47
Project: Eclipse-Postfix-Code-Completion-Juno38   File: CleanUpPreferenceUtil.java   Source Code and License 6 votes vote down vote up
public static Map<String, String> loadSaveParticipantOptions(IScopeContext context) {
	IEclipsePreferences node;
	if (hasSettingsInScope(context)) {
		node= context.getNode(JavaUI.ID_PLUGIN);
	} else {
		IScopeContext instanceScope= InstanceScope.INSTANCE;
		if (hasSettingsInScope(instanceScope)) {
			node= instanceScope.getNode(JavaUI.ID_PLUGIN);
		} else {
			return JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getMap();
		}
	}

	Map<String, String> result= new HashMap<String, String>();
	Set<String> keys= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getKeys();
	for (Iterator<String> iterator= keys.iterator(); iterator.hasNext();) {
        String key= iterator.next();
        result.put(key, node.get(SAVE_PARTICIPANT_KEY_PREFIX + key, CleanUpOptions.FALSE));
       }

	return result;
}
 
Example 48
Project: Eclipse-Postfix-Code-Completion-Juno38   File: ProfileManager.java   Source Code and License 6 votes vote down vote up
/**
 * Update all formatter settings with the settings of the specified profile.
 * @param profile The profile to write to the preference store
 */
private void writeToPreferenceStore(Profile profile, IScopeContext context) {
	final Map<String, String> profileOptions= profile.getSettings();

	for (int i= 0; i < fKeySets.length; i++) {
        updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), profileOptions);
       }

	final IEclipsePreferences uiPrefs= context.getNode(JavaUI.ID_PLUGIN);
	if (uiPrefs.getInt(fProfileVersionKey, 0) != fProfileVersioner.getCurrentVersion()) {
		uiPrefs.putInt(fProfileVersionKey, fProfileVersioner.getCurrentVersion());
	}

	if (context.getName() == InstanceScope.SCOPE) {
		uiPrefs.put(fProfileKey, profile.getID());
	} else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) {
		uiPrefs.put(fProfileKey, profile.getID());
	}
}
 
Example 49
Project: Eclipse-Postfix-Code-Completion-Juno38   File: CleanUpSaveParticipantPreferenceConfiguration.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void performDefaults() {
	if (ProjectScope.SCOPE.equals(fContext.getName()) && !hasSettingsInScope(fContext))
		return;

	enabled(true);

	if (ProjectScope.SCOPE.equals(fContext.getName())) {
		fSettings= CleanUpPreferenceUtil.loadSaveParticipantOptions(InstanceScope.INSTANCE);
	} else {
		fSettings= JavaPlugin.getDefault().getCleanUpRegistry().getDefaultOptions(CleanUpConstants.DEFAULT_SAVE_ACTION_OPTIONS).getMap();
	}
	settingsChanged();

	super.performDefaults();
}
 
Example 50
Project: Eclipse-Postfix-Code-Completion-Juno38   File: CleanUpRefactoringWizard.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public String getColumnText(Object element, int columnIndex) {
	if (columnIndex == 0) {
		return ((IJavaProject)element).getProject().getName();
	} else if (columnIndex == 1) {

		if (fProfileIdsTable == null)
    		fProfileIdsTable= loadProfiles();

		IEclipsePreferences instancePreferences= InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN);

   		final String workbenchProfileId;
   		if (instancePreferences.get(CleanUpConstants.CLEANUP_PROFILE, null) != null) {
   			workbenchProfileId= instancePreferences.get(CleanUpConstants.CLEANUP_PROFILE, null);
   		} else {
   			workbenchProfileId= CleanUpConstants.DEFAULT_PROFILE;
   		}

		return getProjectProfileName((IJavaProject)element, fProfileIdsTable, workbenchProfileId);
	}
	return null;
}
 
Example 51
Project: dawnsci   File: PlottingFactory.java   Source Code and License 6 votes vote down vote up
/**
 * Reads the extension points for the plotting systems registered and returns
 * a plotting system based on the users current preferences.
 * 
 * @return
 */
@SuppressWarnings("unchecked")
public static <T> IPlottingSystem<T> createPlottingSystem() throws Exception {

	final ScopedPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE,"org.dawb.workbench.ui");
	String plotType = store.getString("org.dawb.plotting.system.choice");
	if (plotType.isEmpty()) plotType = System.getProperty("org.dawb.plotting.system.choice");// For Geoff et. al. can override.
	if (plotType==null) plotType = "org.dawb.workbench.editors.plotting.lightWeightPlottingSystem"; // That is usually around

	IPlottingSystem<T> system = createPlottingSystem(plotType);
	if (system!=null) return system;

	IConfigurationElement[] systems = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.dawnsci.plotting.api.plottingClass");
	if (systems.length == 0) {
		return null;
	}

	IPlottingSystem<T> ifnotfound = (IPlottingSystem<T>)systems[0].createExecutableExtension("class");
	store.setValue("org.dawb.plotting.system.choice", systems[0].getAttribute("id"));
	return ifnotfound;
}
 
Example 52
Project: antlr4ide   File: ConsoleTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testPreferenceLogLevelSetting() throws BackingStoreException {
	final Level logLevel1 = ConsoleImpl.getLogLevel();
	Assert.assertEquals(Level.INFO, logLevel1);
	final IEclipsePreferences prefs = InstanceScope.INSTANCE
	        .getNode(ConsoleImpl.QUALIFIER);
	Assert.assertNotNull(prefs);
	final String trace = "TRACE";
	prefs.put(ConsoleImpl.KEY, trace);
	final Level logLevel2 = ConsoleImpl.getLogLevel();
	Assert.assertEquals(Level.TRACE, logLevel2);
	prefs.put(ConsoleImpl.KEY, "INFO");
	final Level logLevel3 = ConsoleImpl.getLogLevel();
	Assert.assertEquals(Level.INFO, logLevel3);
	prefs.clear();
}
 
Example 53
Project: eclipsensis   File: FileAssociationChecker.java   Source Code and License 6 votes vote down vote up
private void initializePreference(String associationId, boolean enablement, String bundleId, String enablementPref)
{
    if(!PREFERENCES.contains(associationId)) {
        boolean enablement2 = enablement;
        if(enablementPref != null) {
            Bundle bundle = Platform.getBundle(bundleId);
            if(bundle != null) {
                IPreferenceStore prefs = new ScopedPreferenceStore(new InstanceScope(), bundle.getSymbolicName());
                if(prefs.contains(enablementPref)) {
                    enablement2 = prefs.getBoolean(enablementPref);
                }
            }
        }
        PREFERENCES.setValue(associationId,Boolean.toString(enablement2));
    }
}
 
Example 54
Project: birt   File: UIUtil.java   Source Code and License 6 votes vote down vote up
public static Color getEclipseEditorForeground( )
{
	ScopedPreferenceStore preferenceStore = new ScopedPreferenceStore( InstanceScope.INSTANCE,
			"org.eclipse.ui.editors" );//$NON-NLS-1$
	Color color = null;
	if ( preferenceStore != null )
	{
		color = preferenceStore.getBoolean( AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT ) ? null
				: createColor( preferenceStore,
						AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
						Display.getCurrent( ) );
	}
	if ( color == null )
	{
		color = Display.getDefault( )
				.getSystemColor( SWT.COLOR_LIST_FOREGROUND );
	}
	return color;
}
 
Example 55
Project: birt   File: UIUtil.java   Source Code and License 6 votes vote down vote up
public static Color getEclipseEditorBackground( )
{
	ScopedPreferenceStore preferenceStore = new ScopedPreferenceStore( InstanceScope.INSTANCE,
			"org.eclipse.ui.editors" );//$NON-NLS-1$
	Color color = null;
	if ( preferenceStore != null )
	{
		color = preferenceStore.getBoolean( AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT ) ? null
				: createColor( preferenceStore,
						AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
						Display.getCurrent( ) );
	}
	if ( color == null )
	{
		color = Display.getDefault( )
				.getSystemColor( SWT.COLOR_LIST_BACKGROUND );
	}
	return color;
}
 
Example 56
Project: DynamicSpotter   File: ServiceClientWrapper.java   Source Code and License 6 votes vote down vote up
private ServiceClientWrapper(String projectName, boolean useDefaults) {
	if (useDefaults) {
		this.host = DEFAULT_SERVICE_HOST;
		this.port = DEFAULT_SERVICE_PORT;
	} else {
		Preferences prefs;
		if (projectName == null) {
			prefs = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
		} else {
			prefs = SpotterProjectSupport.getProjectPreferences(projectName);
		}
		this.host = prefs.get(KEY_SERVICE_HOST, DEFAULT_SERVICE_HOST);
		this.port = prefs.get(KEY_SERVICE_PORT, DEFAULT_SERVICE_PORT);
	}

	this.projectName = projectName;
	this.client = new SpotterServiceClient(host, port);
	this.lastClientException = null;
	this.lastClearTime = System.currentTimeMillis();
}
 
Example 57
Project: n4js   File: AbstractOutlineWorkbenchTest.java   Source Code and License 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	preferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, getEditorId());
	comparer = new IOutlineNodeComparer.Default();

	// when using in XPECT, XPECT already creates the project structure
	if (shouldCreateProjectStructure()) {
		createProjectStructure();
	}
	//
	openXtextDocument();
	openOutlineView();
}
 
Example 58
Project: n4js   File: OsgiExternalLibraryPreferenceStore.java   Source Code and License 5 votes vote down vote up
@Override
protected IStatus doSave(final ExternalLibraryPreferenceModel modelToSave) {
	final IEclipsePreferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
	node.put(CONFIGURATION_KEY, modelToSave.toJsonString());
	try {
		node.flush();
		return OK_STATUS;
	} catch (final BackingStoreException e) {
		final String message = "Unexpected error when trying to persist external library preferences.";
		LOGGER.error(message, e);
		return statusHelper.createError(message, e);
	}
}
 
Example 59
Project: n4js   File: OsgiExternalLibraryPreferenceStore.java   Source Code and License 5 votes vote down vote up
@Override
protected ExternalLibraryPreferenceModel doLoad() {
	final Preferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
	final String jsonString = node.get(CONFIGURATION_KEY, "");
	if (isNullOrEmpty(jsonString)) {
		return ExternalLibraryPreferenceModel.createDefaultForN4Product();
	}
	return ExternalLibraryPreferenceModel.createFromJson(jsonString);
}
 
Example 60
Project: n4js   File: OsgiBinariesPreferenceStore.java   Source Code and License 5 votes vote down vote up
@Override
protected Map<Binary, URI> init() {
	final Map<Binary, URI> initState = super.init();
	final Preferences node = InstanceScope.INSTANCE.getNode(QUALIFIER);
	for (final Binary binary : binariesProvider.getRegisteredBinaries()) {
		recursivePreferencesRead(initState, node, binary);
	}
	return initState;
}