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

The following are top voted examples for showing how to use org.eclipse.core.runtime.preferences.IEclipsePreferences. 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: AgentWorkbench   File: BundleProperties.java   Source Code and License 6 votes vote down vote up
/**
 * return the listener for preferences changes.
 * @return the change listener
 */
private IEclipsePreferences.IPreferenceChangeListener getChangeListener() {
	if (changeListener==null) {
		changeListener = new IEclipsePreferences.IPreferenceChangeListener() {
			@Override
			public void preferenceChange(PreferenceChangeEvent pce) {
				
				if (debug==true) System.out.println("Property '" + pce.getKey() + "' changed from " + pce.getOldValue() + " to "+ pce.getNewValue());
				
				switch(pce.getKey()) {
				case DEF_RUNAS:
					boolean changedExecutionMode = (pce.getOldValue()!=null && pce.getNewValue()!=pce.getOldValue());
					if (changedExecutionMode==true) {
						if (debug==true) System.out.println("Changed Execution Mode: changed from " + pce.getOldValue() + " to "+ pce.getNewValue());
						//TODO if the preference dialog was set to SWT!
					}
				}
			}
		};
	}
	return changeListener;
}
 
Example 3
Project: EclipseMinifyBuilder   File: MinifyBuilder.java   Source Code and License 6 votes vote down vote up
@Override
protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args,
		IProgressMonitor monitor) throws CoreException {
	ProjectScope projectScope = new ProjectScope(getProject());
	IEclipsePreferences prefs = projectScope.getNode(BUILDER_ID);
	if (kind == FULL_BUILD) {
		fullBuild(prefs, monitor);
	} else {
		IResourceDelta delta = getDelta(getProject());
		if (delta == null) {
			fullBuild(prefs, monitor);
		} else {
			incrementalBuild(delta, prefs, monitor);
		}
	}
	return null;
}
 
Example 4
Project: EclipseMinifyBuilder   File: GccMinifier.java   Source Code and License 6 votes vote down vote up
public GccMinifier(MinifyBuilder builder, IFile srcFile, IFile destFile, 
		OutputStream out, IEclipsePreferences prefs)
	throws IOException, CoreException {
	super(builder);
	this.srcFile = srcFile;
	this.out = out;
	this.outCharset = destFile.exists() ? destFile.getCharset() : "ascii";
	console = builder.minifierConsole();

	String optLevel = prefs.get(PrefsAccess.preferenceKey(
			srcFile, MinifyBuilder.GCC_OPTIMIZATION),
			MinifyBuilder.GCC_OPT_WHITESPACE_ONLY);
	switch (optLevel) {
	case MinifyBuilder.GCC_OPT_ADVANCED:
		compilationLevel = CompilationLevel.ADVANCED_OPTIMIZATIONS;
		break;
	case MinifyBuilder.GCC_OPT_SIMPLE:
		compilationLevel = CompilationLevel.SIMPLE_OPTIMIZATIONS;
		break;
	default:
		compilationLevel = CompilationLevel.WHITESPACE_ONLY;
	}
}
 
Example 5
Project: pgcodekeeper   File: DbSource.java   Source Code and License 6 votes vote down vote up
@Override
protected PgDatabase loadInternal(SubMonitor monitor)
        throws IOException, InterruptedException, CoreException {
    String charset = proj.getProjectCharset();
    monitor.subTask(Messages.dbSource_loading_tree);
    IProject project = proj.getProject();

    int filesCount = PgUIDumpLoader.countFiles(project);
    monitor.setWorkRemaining(filesCount);

    IEclipsePreferences pref = proj.getPrefs();
    return PgUIDumpLoader.loadDatabaseSchemaFromIProject(
            project.getProject(),
            getPgDiffArgs(charset, pref.getBoolean(PROJ_PREF.FORCE_UNIX_NEWLINES, true)),
            monitor, null, errors);
}
 
Example 6
Project: pgcodekeeper   File: SQLEditor.java   Source Code and License 6 votes vote down vote up
public DbInfo getCurrentDb() {
    if (currentDB != null) {
        return currentDB;
    }

    IResource res = ResourceUtil.getResource(getEditorInput());
    if (res != null) {
        IEclipsePreferences prefs = PgDbProject.getPrefs(res.getProject());
        if (prefs != null) {
            List<DbInfo> lastStore = DbInfo.preferenceToStore(
                    prefs.get(PROJ_PREF.LAST_DB_STORE_EDITOR, "")); //$NON-NLS-1$
            if (!lastStore.isEmpty()) {
                return lastStore.get(0);
            }
        }
    }
    return null;
}
 
Example 7
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 8
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 9
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 10
Project: eclipse-asciidoctools   File: AsciidocConfiguration.java   Source Code and License 6 votes vote down vote up
private static boolean updateConfigurationFromSettings(AsciidocConfiguration configuration, IProject project) {
	final IScopeContext projectScope = new ProjectScope(project);
	IEclipsePreferences preferences = projectScope.getNode(Activator.PLUGIN_ID);
	try {
		createSettings(project, BACKEND_DEFAULT, RESOURCESPATH_DEFAULT, SOURCESPATH_DEFAULT, STYLESHEETPATH_DEFAULT, TARGETPATH_DEFAULT);
		configuration.setBackend(preferences.get(BACKEND_PROPERTY, BACKEND_DEFAULT));
		configuration.setResourcesPath(preferences.get(RESOURCESPATH_PROPERTY, RESOURCESPATH_DEFAULT));
		configuration.setSourcesPath(preferences.get(SOURCESPATH_PROPERTY, SOURCESPATH_DEFAULT));
		configuration.setStylesheetPath(preferences.get(STYLESHEETPATH_PROPERTY, STYLESHEETPATH_DEFAULT));
		configuration.setTargetPath(preferences.get(TARGETPATH_PROPERTY, TARGETPATH_DEFAULT));
	} catch (BackingStoreException e) {
		Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage(), e));
		return false;
	}
	configuration.source = AsciidocConfigurationSource.SETTINGS;
	return true;
}
 
Example 11
Project: workspacemechanic   File: PreferenceRecorder.java   Source Code and License 6 votes vote down vote up
public void added(NodeChangeEvent event) {
  synchronized (lock) {
    // It's possible that we've stopped recording, but the listeners have
    // not yet been removed.
    // Ensure that we're still recording before writing new data
    if (currState != State.RECORDING) {
      return;
    }

    IEclipsePreferences childPrefs = (IEclipsePreferences) event.getChild();
    addListener(childPrefs);

    changeLog.add(new NodeChanged(true, new Path(event.getParent().absolutePath()), 
        event.getChild().name()));
  }
}
 
Example 12
Project: workspacemechanic   File: PreferenceReconcilerTaskTest.java   Source Code and License 6 votes vote down vote up
public void testCompositeReconcilerReconciles() throws Exception {

    IEclipsePreferences root = mock(IEclipsePreferences.class);
    IEclipsePreferences wee = mock(IEclipsePreferences.class);

    when(root.node(WEE.getPath()))
        .thenReturn(wee);

    // should return an incorrect value
    when(wee.get(WEE.getKey(), null))
        .thenReturn(HAA.getValue());

    // It's a weird idiom, but we have to call this method before the
    // replay so that easy-mock will be aware of the fact that we will
    // be calling it after the replay. Else we get an exception.
    wee.put(WEE.getKey(), WEE.getValue());

    // needs reconciliation
    Reconciler reconciler = new CompositeReconciler(root, HAA,
        new EqualsMatcher(WEE), new SimpleResolver(WEE));

    assertFalse(reconciler.isReconciled());
    reconciler.reconcile(); // causes wee.put to be called.

    verify(wee).flush();
  }
 
Example 13
Project: google-cloud-eclipse   File: AppEngineDeployPreferencesPanelTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testProjectSavedInPreferencesSelected()
    throws ProjectRepositoryException, InterruptedException, BackingStoreException {
  IEclipsePreferences node =
      new ProjectScope(project).getNode(DeployPreferences.PREFERENCE_STORE_QUALIFIER);
  try {
    node.put("project.id", "projectId1");
    node.put("account.email", EMAIL_1);
    model = new DeployPreferences(project);

    initializeProjectRepository();
    when(loginService.getAccounts()).thenReturn(twoAccountSet);
    deployPanel = createPanel(true /* requireValues */);
    deployPanel.latestGcpProjectQueryJob.join();

    ProjectSelector projectSelector = getProjectSelector();
    IStructuredSelection selection = projectSelector.getViewer().getStructuredSelection();
    assertThat(selection.size(), is(1));
    assertThat(((GcpProject) selection.getFirstElement()).getId(), is("projectId1"));
  } finally {
    node.clear();
  }
}
 
Example 14
Project: CodeCheckerEclipsePlugin   File: CcConfiguration.java   Source Code and License 6 votes vote down vote up
private  Map<ConfigTypes, String> getConfigEclipse(IEclipsePreferences pref ) {
    Map<ConfigTypes, String> ret = new HashMap<ConfigTypes, String>();
    for (ConfigTypes k:ConfigTypes.values()){
        if (defaults.containsKey(k))
            ret.put(k,defaults.get(k));
        else
            ret.put(k,"");
    }

    try {
        for (String configKey : pref.keys()) {
            for (ConfigTypes c : configKeys.keySet()) {
                if (configKey.equals(configKeys.get(c))){
                    ret.put(c, pref.get(configKey, ""));
                }
            }
        }
    } catch (BackingStoreException e) {
    }


    return ret;
}
 
Example 15
Project: dsl-devkit   File: ValidPreferenceStore.java   Source Code and License 6 votes vote down vote up
/**
 * Does its best at determining the default value for the given key. Checks
 * the given object's type and then looks in the list of defaults to see if
 * a value exists. If not or if there is a problem converting the value, the
 * default default value for that type is returned.
 *
 * @param key
 *          the key to search
 * @param object
 *          the object who default we are looking for
 * @return Object or <code>null</code>
 */
Object getDefault(final String key, final Object object) {
  final IEclipsePreferences defaults = getDefaultPreferences();
  if (object instanceof String) {
    return defaults.get(key, STRING_DEFAULT_DEFAULT);
  } else if (object instanceof Integer) {
    return Integer.valueOf(defaults.getInt(key, INT_DEFAULT_DEFAULT));
  } else if (object instanceof Double) {
    return new Double(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT));
  } else if (object instanceof Float) {
    return new Float(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT));
  } else if (object instanceof Long) {
    return Long.valueOf(defaults.getLong(key, LONG_DEFAULT_DEFAULT));
  } else if (object instanceof Boolean) {
    return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE : Boolean.FALSE;
  } else {
    return null;
  }
}
 
Example 16
Project: dsl-devkit   File: ValidPreferenceStore.java   Source Code and License 6 votes vote down vote up
/**
 * Return the preference path to search preferences on. This is the list of
 * preference nodes based on the scope contexts for this store. If there are
 * no search contexts set, then return this store's context.
 * <p>
 * Whether or not the default context should be included in the resulting list is specified by the <code>includeDefault</code> parameter.
 * </p>
 *
 * @param includeDefault
 *          <code>true</code> if the default context should be included
 *          and <code>false</code> otherwise
 * @return IEclipsePreferences[]
 * @since 3.4 public, was added in 3.1 as private method
 */
public IEclipsePreferences[] getPreferenceNodes(final boolean includeDefault) {
  // if the user didn't specify a search order, then return the scope that
  // this store was created on. (and optionally the default)
  if (searchContexts == null) {
    if (includeDefault) {
      return new IEclipsePreferences[] {getStorePreferences(), getDefaultPreferences()};
    }
    return new IEclipsePreferences[] {getStorePreferences()};
  }
  // otherwise the user specified a search order so return the appropriate
  // nodes based on it
  int length = searchContexts.length;
  if (includeDefault) {
    length++;
  }
  final IEclipsePreferences[] preferences = new IEclipsePreferences[length];
  for (int i = 0; i < searchContexts.length; i++) {
    preferences[i] = searchContexts[i].getNode(nodeQualifier);
  }
  if (includeDefault) {
    preferences[length - 1] = getDefaultPreferences();
  }
  return preferences;
}
 
Example 17
Project: tlaplus   File: PreferenceStoreHelper.java   Source Code and License 6 votes vote down vote up
/**
    * Stores root file name in project preferences
    * @param project
    * @param rootFilename
    */
public static void storeRootFilename(IProject project, String rootFilename) {
	// If this condition does not hold, the subsequent code but also
	// AddModuleHandler will not work. The claim is that spec files are
	// always in the parent folder of the IProject.
	final IPath path = new Path(rootFilename);
	Assert.isTrue(ResourceHelper.isProjectParent(path.removeLastSegments(1), project),
			project.getLocation().toOSString() + " is *not* a subdirectory of " + rootFilename
					+ ". This is commonly caused by a symlink contained in the latter path.");
	// Store the filename *without* any path information, but prepend the
	// magical PARENT-1-PROJECT-LOC. It indicates that the file can be found
	// *one* level up (hence the "1") from the project location.
	// readProjectRootFile can later easily deduce the relative location of
	// the file.
	rootFilename = ResourceHelper.PARENT_ONE_PROJECT_LOC + path.lastSegment();
       IEclipsePreferences projectPrefs = getProjectPreferences(project);
       projectPrefs.put(IPreferenceConstants.P_PROJECT_ROOT_FILE, rootFilename);
       storePreferences(projectPrefs);        
   }
 
Example 18
Project: tlaplus   File: PreferenceStoreHelper.java   Source Code and License 6 votes vote down vote up
/**
    * Retrieves project root file name
    * @param project
    * @return
    */
public static IFile readProjectRootFile(IProject project) {
	final IEclipsePreferences projectPrefs = getProjectPreferences(project);
	if (projectPrefs != null) {
		String rootFileName = projectPrefs.get(IPreferenceConstants.P_PROJECT_ROOT_FILE,
				IPreferenceConstants.DEFAULT_NOT_SET);
		if (!IPreferenceConstants.DEFAULT_NOT_SET.equals(rootFileName)) {
			final IPath path = new Path(rootFileName);
			if (path.isAbsolute()) {
				// Convert a legacy (absolute) path to the new relative one
				// with the magic PARENT_PROJECT_LOC prefix.
				rootFileName = ResourceHelper.PARENT_ONE_PROJECT_LOC + path.lastSegment(); 
				convertAbsoluteToRelative(projectPrefs, rootFileName);
			}
			final IFile linkedFile = ResourceHelper.getLinkedFile(project, rootFileName);
			Activator.getDefault().logDebug(
					"footFileName = " + (linkedFile != null ? linkedFile.getLocation().toOSString() : null));
			return linkedFile;
		}
	} else {
		Activator.getDefault().logInfo("projectPrefs is null");
	}
	return null;
}
 
Example 19
Project: gwt-eclipse-plugin   File: GWTProjectProperties.java   Source Code and License 6 votes vote down vote up
public static void setFileNamesCopiedToWebInfLib(IProject project,
    List<String> fileNamesCopiedToWebInfLib) throws BackingStoreException {
  IEclipsePreferences prefs = getProjectProperties(project);
  StringBuilder sb = new StringBuilder();
  boolean addPipe = false;
  for (String fileNameCopiedToWebInfLib : fileNamesCopiedToWebInfLib) {
    if (addPipe) {
      sb.append("|");
    } else {
      addPipe = true;
    }

    sb.append(fileNameCopiedToWebInfLib);
  }

  prefs.put(FILES_COPIED_TO_WEB_INF_LIB, sb.toString());
  prefs.flush();
}
 
Example 20
Project: APICloud-Studio   File: HTMLTidyValidator.java   Source Code and License 6 votes vote down vote up
@Override
public void restoreDefaults()
{
	// Wipe the user prefs for the problem severities
	IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(getPreferenceNode());
	for (ProblemType type : ProblemType.values())
	{
		prefs.remove(type.getPrefKey());
	}
	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(BuildPathCorePlugin.getDefault(), e);
	}
	// Let super class handle cleaning up enablement and filters
	super.restoreDefaults();
}
 
Example 21
Project: APICloud-Studio   File: ShellExecutable.java   Source Code and License 6 votes vote down vote up
public static void setPreferenceShellPath(IPath path)
{
	IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(CorePlugin.PLUGIN_ID);
	if (path != null)
	{
		prefs.put(ICorePreferenceConstants.PREF_SHELL_EXECUTABLE_PATH, path.toOSString());
	}
	else
	{
		prefs.remove(ICorePreferenceConstants.PREF_SHELL_EXECUTABLE_PATH);
	}
	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CorePlugin.getDefault(), "Saving preferences failed.", e); //$NON-NLS-1$
	}
	shellPath = null;
	shellEnvironment = null;
}
 
Example 22
Project: APICloud-Studio   File: PreferenceUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Sets if the new files and folders should update their permissions to specific permissions after transferring.
 * 
 * @param shouldSpecific
 *            true if the permissions should be updated, false otherwise
 * @param direction
 *            indicates if this is for upload or download permissions
 */
public static void setSpecificPermissions(boolean shouldSpecific, PermissionDirection direction)
{
	IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(CoreIOPlugin.PLUGIN_ID);
	switch (direction)
	{
		case UPLOAD:
			prefs.putBoolean(IPreferenceConstants.UPLOAD_SPECIFIC_PERMISSIONS, shouldSpecific);
			break;
		case DOWNLOAD:
			prefs.putBoolean(IPreferenceConstants.DOWNLOAD_SPECIFIC_PERMISSIONS, shouldSpecific);
			break;
	}
	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CoreIOPlugin.getDefault(), e);
	}
}
 
Example 23
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 24
Project: APICloud-Studio   File: PreferenceInitializer.java   Source Code and License 6 votes vote down vote up
@Override
public void initializeDefaultPreferences()
{
	IEclipsePreferences prefs = (EclipseUtil.defaultScope()).getNode(JSPlugin.PLUGIN_ID);

	prefs.putBoolean(IPreferenceConstants.COMMENT_INDENT_USE_STAR, DEFAULT_COMMENT_INDENT_USE_STAR);
	// prefs.putBoolean(com.aptana.editor.common.preferences.IPreferenceConstants.LINK_OUTLINE_WITH_EDITOR, true);
	prefs.put(
			com.aptana.editor.common.contentassist.IPreferenceConstants.COMPLETION_PROPOSAL_ACTIVATION_CHARACTERS,
			"."); //$NON-NLS-1$
	prefs.put(
			com.aptana.editor.common.contentassist.IPreferenceConstants.CONTEXT_INFORMATION_ACTIVATION_CHARACTERS,
			".("); //$NON-NLS-1$
	// https://jira.appcelerator.org/browse/APSTUD-4665
	//		prefs.put(com.aptana.editor.common.contentassist.IPreferenceConstants.PROPOSAL_TRIGGER_CHARACTERS, "."); //$NON-NLS-1$
	prefs.put(com.aptana.editor.common.contentassist.IPreferenceConstants.PROPOSAL_TRIGGER_CHARACTERS, ""); //$NON-NLS-1$
	prefs.putBoolean(com.aptana.editor.common.preferences.IPreferenceConstants.EDITOR_AUTO_INDENT, true);
	prefs.putBoolean(com.aptana.editor.common.preferences.IPreferenceConstants.EDITOR_ENABLE_FOLDING, true);

	// mark occurrences
	// prefs.putBoolean(com.aptana.editor.common.preferences.IPreferenceConstants.EDITOR_MARK_OCCURRENCES, true);
}
 
Example 25
Project: che   File: ImportOrganizeTest.java   Source Code and License 6 votes vote down vote up
protected void setOrganizeImportSettings(
    String[] order, int threshold, int staticThreshold, IJavaProject project) {
  IEclipsePreferences scope =
      new ProjectScope(project.getProject()).getNode("org.eclipse.jdt.ui");
  if (order == null) {
    scope.remove(PreferenceConstants.ORGIMPORTS_IMPORTORDER);
    scope.remove(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD);
  } else {
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < order.length; i++) {
      buf.append(order[i]);
      buf.append(';');
    }
    scope.put(PreferenceConstants.ORGIMPORTS_IMPORTORDER, buf.toString());
    scope.put(PreferenceConstants.ORGIMPORTS_ONDEMANDTHRESHOLD, String.valueOf(threshold));
    scope.put(
        PreferenceConstants.ORGIMPORTS_STATIC_ONDEMANDTHRESHOLD, String.valueOf(staticThreshold));
  }
}
 
Example 26
Project: APICloud-Studio   File: PreferenceUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Sets the specific permissions used for new files created when transferring.
 * 
 * @param permissions
 *            permissions in decimal form
 * @param direction
 *            indicates if this is for upload or download permissions
 */
public static void setFilePermissions(long permissions, PermissionDirection direction)
{
	IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode(CoreIOPlugin.PLUGIN_ID);
	switch (direction)
	{
		case UPLOAD:
			prefs.putLong(IPreferenceConstants.UPLOAD_FILE_PERMISSION, permissions);
			break;
		case DOWNLOAD:
			prefs.putLong(IPreferenceConstants.DOWNLOAD_FILE_PERMISSION, permissions);
			break;
	}
	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CoreIOPlugin.getDefault(), e);
	}
}
 
Example 27
Project: gwt-eclipse-plugin   File: GdtPreferences.java   Source Code and License 6 votes vote down vote up
private static void ensureUsingNewSdkRegistrantsKey(IEclipsePreferences instancePrefs, String newKey) {
  try {
    List<String> keys = Arrays.asList(instancePrefs.keys());
    if (!keys.contains(newKey)) {
      String oldKey2;
      // are we using the original "SdkRegistrants" key?
      if (keys.contains(SDK_REGISTRANTS_KEY_PREFIX)) {
        updateSdkRegistrantsKey(instancePrefs, SDK_REGISTRANTS_KEY_PREFIX, newKey);
      } else if (keys.contains((oldKey2 = computeSdkRegistrantsKeyV2()))) {
        // or are we using the 2nd version "SdkRegistrants_installationpath"
        // key?
        updateSdkRegistrantsKey(instancePrefs, oldKey2, newKey);
      }
    }
  } catch (BackingStoreException e) {
    CorePluginLog.logError(e, "Could not check if migration to new SdkRegistrants key format is needed.");
  }
}
 
Example 28
Project: bts   File: ScopedPreferenceStore.java   Source Code and License 6 votes vote down vote up
/**
 * Does its best at determining the default value for the given key. Checks
 * the given object's type and then looks in the list of defaults to see if
 * a value exists. If not or if there is a problem converting the value, the
 * default default value for that type is returned.
 * 
 * @param key
 *            the key to search
 * @param obj
 *            the object who default we are looking for
 * @return Object or <code>null</code>
 */
Object getDefault(String key, Object obj) {
	IEclipsePreferences defaults = getDefaultPreferences();
	if (obj instanceof String) {
		return defaults.get(key, STRING_DEFAULT_DEFAULT);
	} else if (obj instanceof Integer) {
		return new Integer(defaults.getInt(key, INT_DEFAULT_DEFAULT));
	} else if (obj instanceof Double) {
		return new Double(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT));
	} else if (obj instanceof Float) {
		return new Float(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT));
	} else if (obj instanceof Long) {
		return new Long(defaults.getLong(key, LONG_DEFAULT_DEFAULT));
	} else if (obj instanceof Boolean) {
		return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE
				: Boolean.FALSE;
	} else {
		return null;
	}
}
 
Example 29
Project: e4-cookbook-migration-guide   File: ScopedPreferenceStore.java   Source Code and License 6 votes vote down vote up
/**
 * Dispose the receiver.
 */
private void disposePreferenceStoreListener() {

	IEclipsePreferences root = (IEclipsePreferences) Platform
			.getPreferencesService().getRootNode().node(
					Plugin.PLUGIN_PREFERENCE_SCOPE);
	try {
		if (!(root.nodeExists(nodeQualifier))) {
			return;
		}
	} catch (BackingStoreException e) {
		return;// No need to report here as the node won't have the
		// listener
	}

	IEclipsePreferences preferences = getStorePreferences();
	if (preferences == null) {
		return;
	}
	if (preferencesListener != null) {
		preferences.removePreferenceChangeListener(preferencesListener);
		preferencesListener = null;
	}
}
 
Example 30
Project: bts   File: ScopedPreferenceStore.java   Source Code and License 6 votes vote down vote up
/**
 * Dispose the receiver.
 */
private void disposePreferenceStoreListener() {

	IEclipsePreferences root = (IEclipsePreferences) Platform
			.getPreferencesService().getRootNode().node(
					Plugin.PLUGIN_PREFERENCE_SCOPE);
	try {
		if (!(root.nodeExists(nodeQualifier))) {
			return;
		}
	} catch (BackingStoreException e) {
		return;// No need to report here as the node won't have the
		// listener
	}

	IEclipsePreferences preferences = getStorePreferences();
	if (preferences == null) {
		return;
	}
	if (preferencesListener != null) {
		preferences.removePreferenceChangeListener(preferencesListener);
		preferencesListener = null;
	}
}
 
Example 31
Project: PDFReporter-Studio   File: GeneralPrefPage.java   Source Code and License 6 votes vote down vote up
/**
   * @see org.eclipse.jface.preference.IPreferencePage#performOk()
   */
  public boolean performOk() {
      IEclipsePreferences prefs = MsgEditorPreferences.getEclipsePreferenceStore();
      prefs.put(MsgEditorPreferences.GROUP__LEVEL_SEPARATOR, keyGroupSeparator.getText());
      prefs.put(MsgEditorPreferences.FILTER_LOCALES_STRING_MATCHERS,filterLocales.getText());
      prefs.putBoolean(MsgEditorPreferences.UNICODE_UNESCAPE_ENABLED, convertEncodedToUnicode.getSelection());
      prefs.putBoolean(MsgEditorPreferences.NL_SUPPORT_ENABLED,supportNL.getSelection());
      prefs.putBoolean(MsgEditorPreferences.ADD_MSG_EDITOR_BUILDER_TO_JAVA_PROJECTS, setupRbeNatureAutomatically.getSelection());
      prefs.putBoolean(MsgEditorPreferences.KEY_TREE_HIERARCHICAL, keyTreeHierarchical.getSelection());
      prefs.putBoolean(MsgEditorPreferences.KEY_TREE_EXPANDED,  keyTreeExpanded.getSelection());
      prefs.putBoolean(MsgEditorPreferences.FIELD_TAB_INSERTS, fieldTabInserts.getSelection());
      try {
	prefs.flush();
} catch (BackingStoreException e) {
	e.printStackTrace();
}
      refreshEnabledStatuses();
      return super.performOk();
  }
 
Example 32
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 33
Project: bts   File: FixedScopedPreferenceStore.java   Source Code and License 6 votes vote down vote up
/**
 * Does its best at determining the default value for the given key. Checks
 * the given object's type and then looks in the list of defaults to see if
 * a value exists. If not or if there is a problem converting the value, the
 * default default value for that type is returned.
 * 
 * @param key
 *            the key to search
 * @param obj
 *            the object who default we are looking for
 * @return Object or <code>null</code>
 */
Object getDefault(String key, Object obj) {
	IEclipsePreferences defaults = getDefaultPreferences();
	if (obj instanceof String) {
		return defaults.get(key, STRING_DEFAULT_DEFAULT);
	} else if (obj instanceof Integer) {
		return Integer.valueOf(defaults.getInt(key, INT_DEFAULT_DEFAULT));
	} else if (obj instanceof Double) {
		return Double.valueOf(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT));
	} else if (obj instanceof Float) {
		return Float.valueOf(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT));
	} else if (obj instanceof Long) {
		return Long.valueOf(defaults.getLong(key, LONG_DEFAULT_DEFAULT));
	} else if (obj instanceof Boolean) {
		return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE : Boolean.FALSE;
	} else {
		return null;
	}
}
 
Example 34
Project: APICloud-Studio   File: Theme.java   Source Code and License 6 votes vote down vote up
protected void storeDefaults()
{
	// Don't store builtin themes default copy in prefs!
	if (getThemeManager().isBuiltinTheme(getName()))
	{
		return;
	}
	// Only save to defaults if it has never been saved there. Basically take a snapshot of first version and
	// use that as the "default"
	IEclipsePreferences prefs = EclipseUtil.defaultScope().getNode(ThemePlugin.PLUGIN_ID);
	if (prefs == null)
	{
		return; // TODO Log something?
	}
	Preferences preferences = prefs.node(ThemeManager.THEMES_NODE);
	if (preferences == null)
	{
		return;
	}
	String value = preferences.get(getName(), null);
	if (value == null)
	{
		save(EclipseUtil.defaultScope());
	}
}
 
Example 35
Project: filesync4eclipse   File: ProjectSyncPropertyPage.java   Source Code and License 6 votes vote down vote up
public boolean hasChangesInDialog() {
    String currSettings = getEncodedSettings();
    boolean b = !currSettings.equals(oldMappings);

    if(b){
        return true;
    }

    IEclipsePreferences preferences = getPreferences(false);
    boolean useCurrentDate = preferences.getBoolean(
            ProjectProperties.KEY_USE_CURRENT_DATE, false);
    boolean useCurrentDateNew = useCurrentDateField.isSelected();

    if (useCurrentDateNew != useCurrentDate){
        return true;
    }

    boolean includeTeamFiles = preferences.getBoolean(
            ProjectProperties.KEY_INCLUDE_TEAM_PRIVATE, false);
    boolean includeTeamFilesNew = includeTeamFilesField.isSelected();
    if (includeTeamFiles != includeTeamFilesNew){
        return true;
    }
    return false;
}
 
Example 36
Project: jsweet-eclipse-plugin   File: ProjectPreferenceStore.java   Source Code and License 6 votes vote down vote up
private synchronized void insertValue(String name) {
	// check if an insertion is already in-progress
	if (this.inserting) {
		return;
	}
	if (this.projectSpecificSettings && super.contains(name)) {
		return;
	}
	this.inserting = true;
	try {
		IEclipsePreferences projectPreferences = this.getProjectPreferences();
		String value = projectPreferences.get(name, null);
		if (value == null) {
			value = this.preferenceStore.getString(name);
		}
		if (value != null) {
			this.setValue(name, value);
		}
	} finally {
		this.inserting = false;
	}
}
 
Example 37
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 38
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 39
Project: APICloud-Studio   File: UserAgentManager.java   Source Code and License 6 votes vote down vote up
/**
 * Given a project, return the list of active user agent IDs. The current implementation processes only the first
 * (primary) nature ID of the given project. Secondary natures may be taken into consideration at a later point in
 * time
 * 
 * @param project
 *            An {@link IProject}.
 * @return Returns an array of user agent IDs for the main mature of the given project. In case the given project is
 *         null, an empty string array is returned.
 */
public String[] getActiveUserAgentIDs(IProject project)
{
	if (project == null)
	{
		return ArrayUtil.NO_STRINGS;
	}
	// Extract the natures from the given project
	String[] natureIDs = getProjectNatures(project);

	// Look at the project-scope preferences for the active agents.
	ProjectScope scope = new ProjectScope(project);
	IEclipsePreferences node = scope.getNode(CommonEditorPlugin.PLUGIN_ID);
	if (node != null)
	{
		String agents = node.get(IPreferenceConstants.USER_AGENT_PREFERENCE, null);
		if (agents != null)
		{
			Map<String, String[]> userAgents = extractUserAgents(agents);
			return getActiveUserAgentIDs(userAgents, natureIDs);
		}
	}
	// In case we did not find any project-specific settings, use the project's nature IDs to grab the agents that
	// were set in the workspace settings.
	return getActiveUserAgentIDs(natureIDs);
}
 
Example 40
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 41
Project: AgentWorkbench   File: BundleProperties.java   Source Code and License 5 votes vote down vote up
/**
 * Returns the eclipse preferences.
 * @return the eclipse preferences
 */
public IEclipsePreferences getEclipsePreferences() {
	if (eclipsePreferences==null) {
		IScopeContext iScopeContext = ConfigurationScope.INSTANCE;
		eclipsePreferences = iScopeContext.getNode(PlugInActivator.PLUGIN_ID);
		eclipsePreferences.addPreferenceChangeListener(this.getChangeListener());
	}
	return eclipsePreferences;
}
 
Example 42
Project: EclipseMinifyBuilder   File: YuiCssMinifier.java   Source Code and License 5 votes vote down vote up
public YuiCssMinifier(MinifyBuilder builder, IFile srcFile, 
		IFile destFile, OutputStream out, IEclipsePreferences prefs)
				throws CoreException {
	super(builder);
	this.srcFile = srcFile;
	this.inCharset = srcFile.getCharset();
	this.out = out;
	this.outCharset = destFile.exists() ? destFile.getCharset() : srcFile.getCharset();
}
 
Example 43
Project: EclipseMinifyBuilder   File: YuiJsMinifier.java   Source Code and License 5 votes vote down vote up
public YuiJsMinifier(MinifyBuilder builder, IFile srcFile, IFile destFile, 
		OutputStream out, IEclipsePreferences prefs)
	throws IOException, CoreException {
	super (builder);
	preserveSemicolons = prefs.getBoolean(
			PrefsAccess.preferenceKey(srcFile, MinifyBuilder.YUI_PRESERVE_SEMICOLONS), true);
	disableOptimizations = prefs.getBoolean(
			PrefsAccess.preferenceKey(srcFile, MinifyBuilder.YUI_DISABLE_OPTIMIZATIONS), true);
	outCharset = destFile.exists() ? destFile.getCharset() : srcFile.getCharset();
	writer = new OutputStreamWriter(out, outCharset);
	compressor = new JavaScriptCompressor(new BufferedReader(
			new InputStreamReader(srcFile.getContents(), srcFile.getCharset())), 
			new YuiMinifier.MinifyErrorHandler(srcFile));
}
 
Example 44
Project: convertigo-eclipse   File: ConvertigoPluginPreferenceInitializer.java   Source Code and License 5 votes vote down vote up
@Override
public void initializeDefaultPreferences() {
	IEclipsePreferences node = DefaultScope.INSTANCE.getNode("com.twinsoft.convertigo.studio");
	node.put(ConvertigoPlugin.PREFERENCE_LOG_LEVEL, "3");
	node.put(ConvertigoPlugin.PREFERENCE_OPENED_CONSOLES, "");
	node.put(ConvertigoPlugin.PREFERENCE_TRACEPLAYER_PORT, "2323");
	node.put(ConvertigoPlugin.PREFERENCE_TREE_HIGHLIGHT_DETECTED, "true");
	node.put(ConvertigoPlugin.PREFERENCE_IGNORE_NEWS, "false");
	node.put(ConvertigoPlugin.PREFERENCE_LOCAL_BUILD_FOLDER, SWT.getPlatform().startsWith("win") ? "C:\\TMP\\C8O_build" : "/tmp/C8O_build");
}
 
Example 45
Project: eclipse-plugin-commander   File: EclipsePreferencesSerializer.java   Source Code and License 5 votes vote down vote up
public EclipsePreferencesSerializer<T> saveSettings(final T settings) {
	IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(prefereneceId);
	Gson gson = new Gson();
	preferences.put(preferenceKey, gson.toJson(settings));
	try {
		preferences.flush();
	} catch (BackingStoreException e) {
		throw new RuntimeException(e);
	}
	return this;
}
 
Example 46
Project: eclipse-plugin-commander   File: EclipsePreferencesSerializer.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public T loadSettings(final Class<?> settingsTypeClass) {
	IEclipsePreferences preferences = ConfigurationScope.INSTANCE.getNode(prefereneceId);
	Gson gson = new Gson();
	String keyValue = preferences.get(preferenceKey, null);
	if (keyValue != null) {
		return (T) gson.fromJson(keyValue, settingsTypeClass );
	}
	return null;
}
 
Example 47
Project: gw4e.project   File: SettingsManager.java   Source Code and License 5 votes vote down vote up
/**
 * Remove preferences for the passed project
 * 
 * @param project
 * @param values
 * @throws BackingStoreException
 */
public static void remove(IProject project, String[] values) throws BackingStoreException {
	IEclipsePreferences projectPreferences = getProjectPreference(project);
	for (int i = 0; i < values.length; i++) {
		projectPreferences.remove(values[i]);
	}
	projectPreferences.flush();
}
 
Example 48
Project: gw4e.project   File: SettingsManager.java   Source Code and License 5 votes vote down vote up
/**
 * Return the the preference values for the passed project and key
 * 
 * @param project
 * @param key
 * @return
 */
public static String[] getValues(IProject project, String key, boolean projectScoped) {

	IEclipsePreferences projectPreferences = null;
	if (projectScoped) {
		projectPreferences = getProjectPreference(project);
	} else {
		projectPreferences = getGlobalPreference();
	}
	String values = projectPreferences.get(key, "");
	if ((values == null) || (values.trim().length() == 0) && projectScoped) {
		IEclipsePreferences globalPreferences = getGlobalPreference();
		values = globalPreferences.get(key, "");
		final String gloablValues = values;

		Job job = new WorkspaceJob("GW4E Configure Project Preference Job") {
			@Override
			public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
				SubMonitor subMonitor = SubMonitor.convert(monitor, 60);
				try {
					putValues(project, key, fromString(gloablValues), projectScoped);
					return Status.OK_STATUS;
				} catch (Exception e) {
					ResourceManager.logException(e);
					return Status.CANCEL_STATUS;
				} finally {
					subMonitor.done();
				}
			}
		};
		job.setRule(project);
		job.setUser(true);
		job.schedule();
	}
	String[] ret = fromString(values);
	return ret;
}
 
Example 49
Project: gw4e.project   File: SettingsManagerTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testRemove() throws Exception {
	IJavaProject pj = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, false, false);
	String[] values = new String[] { PreferenceManager.SUFFIX_PREFERENCE_FOR_TEST_IMPLEMENTATION };
	SettingsManager.remove(pj.getProject(), values);

	IScopeContext context = new ProjectScope(pj.getProject());
	IEclipsePreferences projectPreferences = context.getNode(Activator.PLUGIN_ID);
	String val = projectPreferences.get(PreferenceManager.SUFFIX_PREFERENCE_FOR_TEST_IMPLEMENTATION, "");

	assertEquals("", val);
}
 
Example 50
Project: pgcodekeeper   File: PgDbProject.java   Source Code and License 5 votes vote down vote up
public IEclipsePreferences getPrefs() {
    IEclipsePreferences prefs = this.prefs;
    if (prefs == null) {
        prefs = getPrefs(project);
        this.prefs = prefs;
    }
    return prefs;
}
 
Example 51
Project: pgcodekeeper   File: PgDbProject.java   Source Code and License 5 votes vote down vote up
/**
 * @return pgCodeKeeper project preferences or null if wrong project
 */
public static IEclipsePreferences getPrefs(IProject proj) {
    try {
        if (proj.hasNature(NATURE.ID)) {
            return new ProjectScope(proj).getNode(PLUGIN_ID.THIS);
        }
    } catch (CoreException ex) {
        Log.log(ex);
    }
    return null;
}
 
Example 52
Project: pgcodekeeper   File: EclipseEnvironment.java   Source Code and License 5 votes vote down vote up
public String getEventValue() {
    Bundle bundle = Platform.getBundle(PLUGIN_ID.THIS);
    if (bundle == null) {
        return NOT_INSTALLED;
    }
    IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(PLUGIN_ID.THIS);
    boolean showOnStartup = prefs.getBoolean(SHOW_BOX_ON_STARTUP, true);
    if (showOnStartup) {
        return TRUE;
    }
    return FALSE;
}
 
Example 53
Project: pgcodekeeper   File: ProjectEditorDiffer.java   Source Code and License 5 votes vote down vote up
public static void saveLastDb(DbInfo lastDb, IProject project) {
    IEclipsePreferences prefs = PgDbProject.getPrefs(project);
    if (prefs != null) {
        prefs.put(PROJ_PREF.LAST_DB_STORE, lastDb.toString());
        try {
            prefs.flush();
        } catch (BackingStoreException ex) {
            Log.log(ex);
        }
    }
}
 
Example 54
Project: pgcodekeeper   File: ProjectEditorDiffer.java   Source Code and License 5 votes vote down vote up
public void diff() {
    Log.log(Log.LOG_INFO, "Started DB update"); //$NON-NLS-1$
    if (warnCheckedElements() < 1 ||
            !OpenProjectUtils.checkVersionAndWarn(proj.getProject(), parent.getShell(), true)) {
        return;
    }

    IEclipsePreferences pref = proj.getPrefs();
    final Differ differ = new Differ(dbRemote.getDbObject(),
            dbProject.getDbObject(), diffTree.getRevertedCopy(), false,
            pref.get(PROJ_PREF.TIMEZONE, ApgdiffConsts.UTC));
    differ.setAdditionalDepciesSource(manualDepciesSource);
    differ.setAdditionalDepciesTarget(manualDepciesTarget);

    Job job = differ.getDifferJob();
    job.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            Log.log(Log.LOG_INFO, "Differ job finished with status " +  //$NON-NLS-1$
                    event.getResult().getSeverity());
            if (event.getResult().isOK()) {
                UiSync.exec(parent, () -> {
                    if (!parent.isDisposed()) {
                        try {
                            showEditor(differ);
                        } catch (PartInitException ex) {
                            ExceptionNotifier.notifyDefault(
                                    Messages.ProjectEditorDiffer_error_opening_script_editor, ex);
                        }
                    }
                });
            }
        }
    });
    job.setUser(true);
    job.schedule();
}
 
Example 55
Project: pgcodekeeper   File: SQLEditor.java   Source Code and License 5 votes vote down vote up
public static void saveLastDb(DbInfo lastDb, IEditorInput inputForProject) {
    IResource res = ResourceUtil.getResource(inputForProject);
    if (res != null) {
        IEclipsePreferences prefs = PgDbProject.getPrefs(res.getProject());
        if (prefs != null) {
            prefs.put(PROJ_PREF.LAST_DB_STORE_EDITOR, lastDb.toString());
            try {
                prefs.flush();
            } catch (BackingStoreException ex) {
                Log.log(ex);
            }
        }
    }
}
 
Example 56
Project: com.onpositive.prefeditor   File: FolderViewerPage.java   Source Code and License 5 votes vote down vote up
public void folderChoosed(String folderPath) {
	this.folderPath = folderPath;
	doResetProvider();
	IEclipsePreferences node = ConfigurationScope.INSTANCE.getNode(PrefEditorPlugin.PLUGIN_ID);
	node.put(CHOOSED_FOLDER_PREF, folderPath);
	try {
		node.flush();
	} catch (BackingStoreException e) {
		PrefEditorPlugin.log(e);
	}
	setViewerTitle(folderPath);
}
 
Example 57
Project: com.onpositive.prefeditor   File: PreferenceView.java   Source Code and License 5 votes vote down vote up
protected void saveChoosedPage(int selectionIndex) {
	IEclipsePreferences node = InstanceScope.INSTANCE.getNode(PrefEditorPlugin.PLUGIN_ID);
	node.putInt(CHOOSED_PAGE_PREF, selectionIndex);
	try {
		node.flush();
	} catch (BackingStoreException e) {
		PrefEditorPlugin.log(e);
	}
}
 
Example 58
Project: com.onpositive.prefeditor   File: PreferenceView.java   Source Code and License 5 votes vote down vote up
protected void saveBoolPref(String key, boolean value) {
	IEclipsePreferences node = InstanceScope.INSTANCE.getNode(PrefEditorPlugin.PLUGIN_ID);
	node.putBoolean(key, value);
	try {
		node.flush();
	} catch (BackingStoreException e) {
		PrefEditorPlugin.log(e);
	}
}
 
Example 59
Project: com.onpositive.prefeditor   File: PlatformPreferenceProvider.java   Source Code and License 5 votes vote down vote up
@Override
public void removed(NodeChangeEvent event) {
	if (event.getChild() instanceof IEclipsePreferences) { 
		((IEclipsePreferences) event.getChild()).removePreferenceChangeListener(changeListener);
	}
	if (tracking) {
		preferenceEntries.remove(event.getChild().absolutePath());
		firePreferencesUpdated("");
	}
}
 
Example 60
Project: com.onpositive.prefeditor   File: PlatformPreferenceProvider.java   Source Code and License 5 votes vote down vote up
@Override
public void added(NodeChangeEvent event) {
	if (tracking && event.getChild() instanceof IEclipsePreferences) {
		((IEclipsePreferences) event.getChild()).addPreferenceChangeListener(changeListener);
		loadPrefsFromNode(event.getChild());
		firePreferencesUpdated("");
	}
}