List of usage examples for org.eclipse.jface.commands PersistentState setShouldPersist
public void setShouldPersist(final boolean persisted)
From source file:org.eclipse.ui.internal.commands.CommandStateProxy.java
License:Open Source License
/** * Loads the state, if possible. If the state is loaded, then the member * variables are updated accordingly and the state is told to load its value * from the preference store./* ww w . ja v a2s. c om*/ * * @param readPersistence * Whether the persistent state for this object should be read. * @return <code>true</code> if the state is now non-null; * <code>false</code> otherwise. */ private final boolean loadState(final boolean readPersistence) { if (state == null) { try { state = (State) configurationElement.createExecutableExtension(stateAttributeName); state.setId(getId()); configurationElement = null; // Try to load the persistent state, if possible. if (readPersistence && state instanceof PersistentState) { final PersistentState persistentState = (PersistentState) state; persistentState.setShouldPersist(true); } load(preferenceStore, preferenceKey); // Transfer the local listeners to the real state. final Object[] listenerArray = getListeners(); for (int i = 0; i < listenerArray.length; i++) { state.addListener((IStateListener) listenerArray[i]); } clearListeners(); return true; } catch (final ClassCastException e) { final String message = "The proxied state was the wrong class"; //$NON-NLS-1$ final IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, message, e); WorkbenchPlugin.log(message, status); return false; } catch (final CoreException e) { final String message = "The proxied state for '" //$NON-NLS-1$ + configurationElement.getAttribute(stateAttributeName) + "' could not be loaded"; //$NON-NLS-1$ IStatus status = new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, 0, message, e); WorkbenchPlugin.log(message, status); return false; } } return true; }