List of usage examples for org.eclipse.jface.commands PersistentState save
public abstract void save(final IPreferenceStore store, final String preferenceKey);
From source file:org.eclipse.ui.internal.commands.CommandService.java
License:Open Source License
public final void dispose() { commandPersistence.dispose();// w w w .j a v a 2s .c o m /* * All state on all commands neeeds to be disposed. This is so that the * state has a chance to persist any changes. */ final Command[] commands = commandManager.getAllCommands(); for (int i = 0; i < commands.length; i++) { final Command command = commands[i]; final String[] stateIds = command.getStateIds(); for (int j = 0; j < stateIds.length; j++) { final String stateId = stateIds[j]; final State state = command.getState(stateId); if (state instanceof PersistentState) { final PersistentState persistentState = (PersistentState) state; if (persistentState.shouldPersist()) { persistentState.save(PrefUtil.getInternalPreferenceStore(), createPreferenceKey(command, stateId)); } } } } commandCallbacks = null; }
From source file:org.eclipse.ui.internal.commands.CommandStateProxy.java
License:Open Source License
public final void dispose() { if (state != null) { state.dispose();/*w ww .jav a 2 s. co m*/ if (state instanceof PersistentState) { final PersistentState persistableState = (PersistentState) state; if (persistableState.shouldPersist() && preferenceStore != null && preferenceKey != null) { persistableState.save(preferenceStore, preferenceKey); } } } }
From source file:org.eclipse.ui.tests.commands.StateTest.java
License:Open Source License
public final void testTextPreference() { final ICommandService commandService = (ICommandService) fWorkbench.getService(ICommandService.class); final Command command = commandService.getCommand(COMMAND_ID); State state = command.getState(TEXT_STATE_ID); state.setValue(TEXT_HELLO);/* w ww. j ava 2 s.c o m*/ assertTrue(state instanceof PersistentState); PersistentState pstate = (PersistentState) state; IPreferenceStore preferenceStore = TestPlugin.getDefault().getPreferenceStore(); pstate.save(preferenceStore, COMMAND_ID + "." + TEXT_STATE_ID); TextState nstate = new TextState(); assertNull(nstate.getValue()); nstate.load(preferenceStore, COMMAND_ID + "." + TEXT_STATE_ID); assertEquals(TEXT_HELLO, nstate.getValue()); }