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

The following examples show how to use org.eclipse.core.runtime.preferences.InstanceScope. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractPreferencePage.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Switches the search scope of the preference store to use [Project, Instance, Configuration] if values are project
 * specific, and [Instance, Configuration] otherwise. This implementation requires that the given preference store
 * is based on the Project preference store when the page is used as a Properties page. (This is done in
 * {@link #doGetPreferenceStore()}).
 */
@SuppressWarnings("deprecation")
private void handleUseProjectSettings() {
	// Note: uses the pre Eclipse 3.6 way of specifying search scopes (deprecated since 3.6)
	boolean isUseProjectSettings = useProjectSettingsButton.getSelection();
	link.setEnabled(!isUseProjectSettings);
	if (!isUseProjectSettings) {
		((FixedScopedPreferenceStore) getPreferenceStore()).setSearchContexts(new IScopeContext[] {
				new InstanceScope(), new ConfigurationScope() });
	} else {
		((FixedScopedPreferenceStore) getPreferenceStore()).setSearchContexts(new IScopeContext[] {
				new ProjectScope(currentProject()), new InstanceScope(), new ConfigurationScope() });
		setProjectSpecificValues();
	}
	updateFieldEditors(isUseProjectSettings);
}
 
Example #2
Source File: ControlFlowViewSortingTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Before Test
 */
@Override
@Before
public void before() {

    try {
        IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
        defaultPreferences.put(ITmfTimePreferencesConstants.TIME_ZONE, "GMT-05:00");
        TmfTimestampFormat.updateDefaultFormats();

        String tracePath = FileUtils.toFile(FileLocator.toFileURL(CtfTestTrace.SYNC_DEST.getTraceURL())).getAbsolutePath();
        fViewBot = fBot.viewByTitle("Control Flow");
        fViewBot.show();
        SWTBotUtils.openTrace(TRACE_PROJECT_NAME, tracePath, KERNEL_TRACE_TYPE);
        fViewBot.setFocus();
    } catch (IOException e) {
        fail();
    }
}
 
Example #3
Source File: ExecutableEntry.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This operation loads the ExecutableEntry from Eclipse Preferences. 
 * @param prefId
 */
public void loadFromPreferences(String prefId) {
	// Get the Application preferences
	IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(prefId);
	try {
		for (String key : prefs.keys()) {
			String pref = prefs.get(key, "");
			if (!pref.isEmpty()) {
				allowedValues.add(pref);
				allowedValueToURI.put(pref, URI.create(key));
			}
		}
	} catch (BackingStoreException e) {
		logger.error(getClass().getName() + " Exception!", e);
	}

	if (!allowedValues.isEmpty()) {
		allowedValues.add(0, "Select Application");
		setDefaultValue(allowedValues.get(0));
	} else {
		allowedValues.add("Import Application");
		setDefaultValue(allowedValues.get(0));
	}
}
 
Example #4
Source File: CommandState.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 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 #5
Source File: AddInPreferencePage.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Gets the manifest URL.
 * 
 * @return the manifest URL
 */
private String getManifestURL() {
    final String res;

    final Preferences preferences = InstanceScope.INSTANCE.getNode(AddInPreferenceInitializer.SCOPE);
    final String host = preferences.get(AddInPreferenceInitializer.HOST_PREFERENCE,
            AddInPreferenceInitializer.DEFAULT_HOST);
    final String port = preferences.get(AddInPreferenceInitializer.PORT_PREFERENCE,
            String.valueOf(AddInPreferenceInitializer.DEFAULT_PORT));
    if (AddInPreferenceInitializer.DEFAULT_HOST.equals(host)) {
        res = "http://localhost:" + port + "/assets/manifest.xml";
    } else {
        res = "http://" + host + ":" + port + "/assets/manifest.xml";
    }

    return res;
}
 
Example #6
Source File: OsgiBinariesPreferenceStore.java    From n4js with Eclipse Public License 1.0 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 #7
Source File: TestTraceOffsetting.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Initialization, creates a temp trace
 *
 * @throws IOException
 *             should not happen
 */
@Before
public void init() throws IOException {
    SWTBotUtils.initialize();
    Thread.currentThread().setName("SWTBot Thread"); // for the debugger
    /* set up for swtbot */
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    fLogger.removeAllAppenders();
    fLogger.addAppender(new ConsoleAppender(new SimpleLayout()));
    fBot = new SWTWorkbenchBot();

    IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    defaultPreferences.put(ITmfTimePreferencesConstants.TIME_ZONE, "GMT-05:00");
    TmfTimestampFormat.updateDefaultFormats();

    /* finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
    fLocation = File.createTempFile("sample", ".xml");
    try (BufferedRandomAccessFile braf = new BufferedRandomAccessFile(fLocation, "rw")) {
        braf.writeBytes(TRACE_START);
        for (int i = 0; i < NUM_EVENTS; i++) {
            braf.writeBytes(makeEvent(i * 100, i % 4));
        }
        braf.writeBytes(TRACE_END);
    }
}
 
Example #8
Source File: PlottingFactory.java    From dawnsci with Eclipse Public License 1.0 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 #9
Source File: ThemeManager.java    From tm4e with Eclipse Public License 1.0 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 #10
Source File: CleanUpPreferenceUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 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 #11
Source File: FilterViewerTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Initialization, creates a temp trace
 *
 * @throws IOException
 *             should not happen
 */
@BeforeClass
public static void init() throws IOException {
    IEclipsePreferences defaultPreferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    defaultPreferences.put(ITmfTimePreferencesConstants.TIME_ZONE, "GMT-05:00");
    TmfTimestampFormat.updateDefaultFormats();

    SWTBotUtils.initialize();
    Thread.currentThread().setName("SWTBot Thread"); // for the debugger
    /* set up for swtbot */
    SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
    fLogger.removeAllAppenders();
    fLogger.addAppender(new ConsoleAppender(new SimpleLayout()));
    fBot = new SWTWorkbenchBot();

    /* finish waiting for eclipse to load */
    WaitUtils.waitForJobs();
    fFileLocation = File.createTempFile("sample", ".xml");
    try (BufferedRandomAccessFile braf = new BufferedRandomAccessFile(fFileLocation, "rw")) {
        braf.writeBytes(TRACE_START);
        for (int i = 0; i < 100; i++) {
            braf.writeBytes(makeEvent(i * 100, i % 4));
        }
        braf.writeBytes(TRACE_END);
    }
}
 
Example #12
Source File: Util.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the line separator found in the given text.
 * If it is null, or not found return the line delimiter for the given project.
 * If the project is null, returns the line separator for the workspace.
 * If still null, return the system line separator.
 */
public static String getLineSeparator(String text, IJavaProject project) {
	String lineSeparator = null;

	// line delimiter in given text
	if (text != null && text.length() != 0) {
		lineSeparator = findLineSeparator(text.toCharArray());
		if (lineSeparator != null)
			return lineSeparator;
	}

	if (Platform.isRunning()) {
		// line delimiter in project preference
		IScopeContext[] scopeContext;
		if (project != null) {
			scopeContext= new IScopeContext[] { new ProjectScope(project.getProject()) };
			lineSeparator= Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
			if (lineSeparator != null)
				return lineSeparator;
		}

		// line delimiter in workspace preference
		scopeContext= new IScopeContext[] { InstanceScope.INSTANCE };
		lineSeparator = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
		if (lineSeparator != null)
			return lineSeparator;
	}

	// system line delimiter
	return org.eclipse.jdt.internal.compiler.util.Util.LINE_SEPARATOR;
}
 
Example #13
Source File: LineSeparators.java    From eclipse-encoding-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public static String ofWorkspace() {
	IPreferencesService prefs = Platform.getPreferencesService();
	IScopeContext[] scopeContext = new IScopeContext[] { InstanceScope.INSTANCE };
	String lineSeparator = prefs.getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
	if (lineSeparator == null) {
		lineSeparator = System.getProperty("line.separator");
	}
	return toLabel(lineSeparator);
}
 
Example #14
Source File: TLCPreferenceInitializer.java    From tlaplus with MIT License 5 votes vote down vote up
/**
   * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
   */
  public void initializeDefaultPreferences()
  {
      final IPreferenceStore uiPreferencesStore = TLCUIActivator.getDefault().getPreferenceStore();
      final IPreferenceStore tlcPreferencesStore = TLCActivator.getDefault().getPreferenceStore();

      tlcPreferencesStore.setDefault(TLCActivator.I_TLC_SNAPSHOT_KEEP_COUNT, 10);

      // This is so bad.. we store them in parallel because one is needed by plugin relied upon the PreferencePage
      //      and the other by a plugin which is on the opposite side of the dependency. (TLCModelLaunchDelegate)
      uiPreferencesStore.setDefault(TLCActivator.I_TLC_SNAPSHOT_KEEP_COUNT, 10);

      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_TRACE_MAX_SHOW_ERRORS, 10000);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_POPUP_ERRORS, true);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_REVALIDATE_ON_MODIFY, true);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_DEFAULT_WORKERS_COUNT,
      							  TLCConsumptionProfile.LOCAL_NORMAL.getWorkerThreads());
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_MAXIMUM_HEAP_SIZE_DEFAULT, MAX_HEAP_SIZE_DEFAULT);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_MAXSETSIZE_DEFAULT, TLCGlobals.setBound);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_FPBITS_DEFAULT, 1);
      uiPreferencesStore.setDefault(ITLCPreferenceConstants.I_TLC_FPSETIMPL_DEFAULT, FPSetFactory.getImplementationDefault());
      // store.setDefault(ITLCPreferenceConstants.I_TLC_DELETE_PREVIOUS_FILES, true);

// By default we want the Toolbox to show a modal progress dialog upon TLC
// startup. A user can opt to subsequently suppress the dialog.
// This restores the behavior prior to https://bugs.eclipse.org/146205#c10.
      if (!uiPreferencesStore.contains(ITLCPreferenceConstants.I_TLC_SHOW_MODAL_PROGRESS)) {
	final IEclipsePreferences node = InstanceScope.INSTANCE
			.getNode(WorkbenchPlugin.getDefault().getBundle().getSymbolicName());
	node.putBoolean(IPreferenceConstants.RUN_IN_BACKGROUND, false);
	try {
		node.flush();
	} catch (final BackingStoreException e) {
		TLCUIActivator.getDefault().logError("Error trying to flush the workbench plugin preferences store.",
				e);
	}
	uiPreferencesStore.setValue(ITLCPreferenceConstants.I_TLC_SHOW_MODAL_PROGRESS, true);
}
  }
 
Example #15
Source File: PortFieldEditor.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected boolean checkState() {
    boolean res;

    if (super.checkState()) {
        final Preferences preferences = InstanceScope.INSTANCE.getNode(AddInPreferenceInitializer.SCOPE);
        final String started = preferences.get(AddInPreferenceInitializer.STARTED_PREFERENCE,
                String.valueOf(false));
        final Text text = getTextControl();
        if (Boolean.valueOf(started)) {
            res = true;
            clearErrorMessage();
        } else if (text == null) {
            res = false;
        } else {
            try (ServerSocket socket = new ServerSocket(getIntValue(), 10, InetAddress.getByName("0.0.0.0"))) {
                res = true;
                clearErrorMessage();
            } catch (IOException e) {
                res = false;
                showErrorMessage(e.getMessage());
            }
        }
    } else {
        res = false; // messages handled by super.checkState()
    }

    return res;
}
 
Example #16
Source File: M2DocAddInPlugin.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    final Preferences preferences = InstanceScope.INSTANCE.getNode(AddInPreferenceInitializer.SCOPE);
    final String started = preferences.get(AddInPreferenceInitializer.STARTED_PREFERENCE,
            String.valueOf(false));
    if (Boolean.valueOf(started)) {
        final String host = preferences.get(AddInPreferenceInitializer.HOST_PREFERENCE,
                AddInPreferenceInitializer.DEFAULT_HOST);
        final String port = preferences.get(AddInPreferenceInitializer.PORT_PREFERENCE,
                String.valueOf(AddInPreferenceInitializer.DEFAULT_PORT));
        startServer(host, Integer.valueOf(port));
    }
}
 
Example #17
Source File: SearchLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public SearchLabelProvider(JavaSearchResultPage page) {
	super(DEFAULT_SEARCH_TEXTFLAGS, DEFAULT_SEARCH_IMAGEFLAGS);
	addLabelDecorator(new ProblemsLabelDecorator(null));

	fPage= page;
	fLabelProviderMap= new HashMap<IMatchPresentation, ILabelProvider>(5);

	fSearchPreferences= new ScopedPreferenceStore(InstanceScope.INSTANCE, NewSearchUI.PLUGIN_ID);
	fSearchPropertyListener= new IPropertyChangeListener() {
		public void propertyChange(PropertyChangeEvent event) {
			doSearchPropertyChange(event);
		}
	};
	fSearchPreferences.addPropertyChangeListener(fSearchPropertyListener);
}
 
Example #18
Source File: ThemeManager.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Remove preference change listener to observe changed of Eclipse E4 Theme and
 * TextMate theme association with grammar.
 * 
 * @param themeChangeListener
 */
public void removePreferenceChangeListener(IPreferenceChangeListener themeChangeListener) {
	// Observe change of Eclipse E4 Theme
	IEclipsePreferences preferences = PreferenceUtils.getE4PreferenceStore();
	if (preferences != null) {
		preferences.removePreferenceChangeListener(themeChangeListener);
	}
	// Observe change of TextMate Theme association
	preferences = InstanceScope.INSTANCE.getNode(TMUIPlugin.PLUGIN_ID);
	if (preferences != null) {
		preferences.removePreferenceChangeListener(themeChangeListener);
	}
}
 
Example #19
Source File: ParallelBuildEnabledTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testIsParallelBuildEnabledInWorkspace() {
	// preference and constant ResourcesPlugin#PREF_MAX_CONCURRENT_BUILDS only available on o.e.core.resources >= 3.13 
	if (Platform.getBundle(ResourcesPlugin.PI_RESOURCES).getVersion().compareTo(new Version(3,13,0)) < 0) {
		return; // running on too old platform
	}
	int maxConcurrentProjectBuilds = new ScopedPreferenceStore(InstanceScope.INSTANCE, ResourcesPlugin.PI_RESOURCES).getInt("maxConcurrentBuilds");
	assertEquals("parallel build was not enabled", 8, maxConcurrentProjectBuilds);
}
 
Example #20
Source File: LaunchUtilities.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
   * Set the debug request timeout of a vm in ms, if supported by the vm implementation.
   */
  public static void setDebugTimeout(VirtualMachine vm) {
      IEclipsePreferences node = InstanceScope.INSTANCE.getNode(JDIDebugPlugin.getUniqueIdentifier());
      int timeOut = node.getInt(JDIDebugModel.PREF_REQUEST_TIMEOUT, 0);
      if (timeOut <= 0) {
	return;
}
      if (vm instanceof org.eclipse.jdi.VirtualMachine) {
          org.eclipse.jdi.VirtualMachine vm2 = (org.eclipse.jdi.VirtualMachine) vm;
          vm2.setRequestTimeout(timeOut);
      }
  }
 
Example #21
Source File: XdsPlugin.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public void start(BundleContext context) throws Exception {
	super.start(context);
	plugin = this;
	XdsPlugin.context = context;
	
	// to force load com.excelsior.core.ide plugin
	IdeCore.instance();
	
	TodoTaskMarkerBuilder.install();
	
	// Set default encoding to cp866 if it exists in jvm:
       if (TextEncoding.isCodepageSupported(TextEncoding.CodepageId.CODEPAGE_866.charsetName)) {
           InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES).put(ResourcesPlugin.PREF_ENCODING, EncodingUtils.DOS_ENCODING); //$NON-NLS-1$
       }
       
       InjectorFactory.getDefault().
	addBinding(IXdsConsoleFactory.class).implementedBy(XdsConsoleManager.class);
	
	new RefreshXdsDecoratorJob().schedule();
	
	Display.getDefault().asyncExec(new Runnable() {
		@Override
		public void run() {
			for (ColorStreamType colorStreamType : ColorStreamType.values()) {
				SharedResourceManager.createColor(colorStreamType.getRgb());
			}
			
			// force loading of the editor plugin, because it contributes the IModulaSyntaxColorer service.
			loadPlugins(Arrays.asList("com.excelsior.xds.ui.editor")); //$NON-NLS-1$
		}
	});
}
 
Example #22
Source File: Preferences.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private Preferences setMembersSortOrder(String sortOrder) {
	if (sortOrder != null) {
		IEclipsePreferences fPreferenceStore = InstanceScope.INSTANCE.getNode(IConstants.PLUGIN_ID);
		fPreferenceStore.put(MembersOrderPreferenceCacheCommon.APPEARANCE_MEMBER_SORT_ORDER, sortOrder);
	}
	return this;
}
 
Example #23
Source File: ImageServiceMock.java    From dawnsci with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public ImageServiceBean createBeanFromPreferences() {
	
	ImageServiceBean imageServiceBean = new ImageServiceBean();
	
	if (Platform.getPreferencesService() != null) { // Normally
		IPreferenceStore store            = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.dawnsci.plotting");
		imageServiceBean.setOrigin(ImageOrigin.forLabel(store.getString(BasePlottingConstants.ORIGIN_PREF)));
		imageServiceBean.setHistogramType(HistoType.forLabel(store.getString(BasePlottingConstants.HISTO_PREF)));
		imageServiceBean.setMinimumCutBound(HistogramBound.fromString(store.getString(BasePlottingConstants.MIN_CUT)));
		imageServiceBean.setMaximumCutBound(HistogramBound.fromString(store.getString(BasePlottingConstants.MAX_CUT)));
		imageServiceBean.setNanBound(HistogramBound.fromString(store.getString(BasePlottingConstants.NAN_CUT)));
		imageServiceBean.setLo(store.getDouble(BasePlottingConstants.HISTO_LO));
		imageServiceBean.setHi(store.getDouble(BasePlottingConstants.HISTO_HI));		
		
		try {
			
			imageServiceBean.setPalette(makeJetPalette());

		} catch (Exception e) {
			// Ignored
		}
		
	} else { // Hard code something
		
		imageServiceBean.setOrigin(ImageOrigin.TOP_LEFT);
		imageServiceBean.setHistogramType(HistoType.OUTLIER_VALUES);
		imageServiceBean.setMinimumCutBound(HistogramBound.DEFAULT_MINIMUM);
		imageServiceBean.setMaximumCutBound(HistogramBound.DEFAULT_MAXIMUM);
		imageServiceBean.setNanBound(HistogramBound.DEFAULT_NAN);
		imageServiceBean.setLo(00.01);
		imageServiceBean.setHi(99.99);		
		imageServiceBean.setPalette(makeJetPalette());
	}

	return imageServiceBean;
}
 
Example #24
Source File: StandardPreferenceManager.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public static void initializeMavenPreferences() {

		IEclipsePreferences m2eAptPrefs = DefaultScope.INSTANCE.getNode(M2E_APT_ID);
		if (m2eAptPrefs != null) {
			m2eAptPrefs.put(M2E_APT_ID + ".mode", "jdt_apt");
		}
		
		IEclipsePreferences store = InstanceScope.INSTANCE.getNode(IMavenConstants.PLUGIN_ID);
		store.put(MavenPreferenceConstants.P_OUT_OF_DATE_PROJECT_CONFIG_PB, ProblemSeverity.warning.toString());
	}
 
Example #25
Source File: CordovaEngineProvider.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void engineFound(HybridMobileEngine engine) {
	initEngineList();
	if(engineList.add(engine)){
		IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(HybridCore.PLUGIN_ID);
		preferences.put(engine.getName(), engine.getSpec());
	}
}
 
Example #26
Source File: TmfAlignmentSynchronizer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private IPreferenceChangeListener createPreferenceListener() {
    IPreferenceChangeListener listener = event -> {
        if (event.getKey().equals(ITmfUIPreferences.PREF_ALIGN_VIEWS)) {
            Object oldValue = event.getOldValue();
            Object newValue = event.getNewValue();
            if (Boolean.toString(false).equals(oldValue) && Boolean.toString(true).equals(newValue)) {
                realignViews();
            } else if (Boolean.toString(true).equals(oldValue) && Boolean.toString(false).equals(newValue)) {
                restoreViews();
            }
        }
    };
    InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).addPreferenceChangeListener(listener);
    return listener;
}
 
Example #27
Source File: GrammarRegistryManager.java    From tm4e with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Load TextMate grammars from preferences.
 */
private void loadGrammarsFromPreferences() {
	// Load grammar definitions from the
	// "${workspace_loc}/metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.tm4e.registry.prefs"
	IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(TMEclipseRegistryPlugin.PLUGIN_ID);
	String json = prefs.get(PreferenceConstants.GRAMMARS, null);
	if (json != null) {
		IGrammarDefinition[] definitions = PreferenceHelper.loadGrammars(json);
		for (IGrammarDefinition definition : definitions) {
			userCache.registerGrammarDefinition(definition);
		}
	}
}
 
Example #28
Source File: AllCleanUpsAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void installPreferenceListener() {
   fPreferenceChangeListener= new IPreferenceChangeListener() {
	public void preferenceChange(PreferenceChangeEvent event) {
		if (event.getKey().equals(CleanUpConstants.SHOW_CLEAN_UP_WIZARD)) {
			updateActionLabel();
		}
	}
};
InstanceScope.INSTANCE.getNode(JavaUI.ID_PLUGIN).addPreferenceChangeListener(fPreferenceChangeListener);
  }
 
Example #29
Source File: Preferences.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public Preferences setFilteredTypes(List<String> filteredTypes) {
	this.filteredTypes = (filteredTypes == null) ? Collections.emptyList() : filteredTypes;
	IEclipsePreferences pref = InstanceScope.INSTANCE.getNode(IConstants.PLUGIN_ID);
	pref.put(TypeFilter.TYPEFILTER_ENABLED, String.join(";", filteredTypes));
	JavaLanguageServerPlugin.getInstance().getTypeFilter().dispose();
	return this;
}
 
Example #30
Source File: EditorConfigUIPlugin.java    From editorconfig-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Flushes the instance scope of this plug-in.
 * 
 */
public static void flushInstanceScope() {
	try {
		InstanceScope.INSTANCE.getNode(EditorConfigUIPlugin.PLUGIN_ID).flush();
	} catch (BackingStoreException e) {
		log(e);
	}
}