mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
state will be null if file deleted
we must create empty (initial) state to reinit component
This commit is contained in:
+8
-2
@@ -298,7 +298,7 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable {
|
||||
}
|
||||
|
||||
Class<T> stateClass = ComponentSerializationUtil.getStateClass(component.getClass());
|
||||
if (LOG.isDebugEnabled()) {
|
||||
if (LOG.isDebugEnabled() && getDefaultState(component, name, stateClass) != null) {
|
||||
LOG.error(name + " has default state, but not marked to load it");
|
||||
}
|
||||
|
||||
@@ -312,9 +312,15 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable {
|
||||
}
|
||||
|
||||
StateStorage stateStorage = getStateStorageManager().getStateStorage(storageSpec);
|
||||
boolean forcedState = false;
|
||||
if (stateStorage != null && (stateStorage.hasState(component, name, stateClass, reloadData) ||
|
||||
(changedStorages != null && changedStorages.contains(stateStorage)))) {
|
||||
(forcedState = changedStorages != null && changedStorages.contains(stateStorage)))) {
|
||||
state = stateStorage.getState(component, name, stateClass, state);
|
||||
if (state == null && forcedState) {
|
||||
// state will be null if file deleted
|
||||
// we must create empty (initial) state to reinit component
|
||||
state = DefaultStateSerializer.deserializeState(new Element("state"), stateClass, null);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -70,11 +70,13 @@ public class FileBasedStorage extends XmlElementStorage {
|
||||
@Override
|
||||
public void fileDeleted(@NotNull VirtualFileEvent event) {
|
||||
myCachedVirtualFile = null;
|
||||
listener.storageFileChanged(event, FileBasedStorage.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileCreated(@NotNull VirtualFileEvent event) {
|
||||
myCachedVirtualFile = event.getFile();
|
||||
listener.storageFileChanged(event, FileBasedStorage.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user