This commit is contained in:
Alexey Kudravtsev
2012-04-16 13:54:25 +04:00
parent 3fe4b30e1a
commit 53e4b17e79
2 changed files with 45 additions and 40 deletions
@@ -331,50 +331,51 @@ public class ProjectImpl extends ComponentManagerImpl implements ProjectEx {
public void save() {
if (ApplicationManagerEx.getApplicationEx().isDoNotSave()) return; //no need to save
if (mySavingInProgress.compareAndSet(false, true)) {
try {
if (isToSaveProjectName()) {
final IProjectStore stateStore = getStateStore();
final VirtualFile baseDir = stateStore.getProjectBaseDir();
if (baseDir != null && baseDir.isValid()) {
final VirtualFile ideaDir = baseDir.findChild(DIRECTORY_STORE_FOLDER);
if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) {
final File nameFile = new File(ideaDir.getPath(), ".name");
try {
FileUtil.writeToFile(nameFile, getName().getBytes("UTF-8"), false);
myOldName = null;
}
catch (IOException e) {
LOG.info("Unable to store project name to: " + nameFile.getPath());
}
if (!mySavingInProgress.compareAndSet(false, true)) {
return;
}
try {
if (isToSaveProjectName()) {
final IProjectStore stateStore = getStateStore();
final VirtualFile baseDir = stateStore.getProjectBaseDir();
if (baseDir != null && baseDir.isValid()) {
final VirtualFile ideaDir = baseDir.findChild(DIRECTORY_STORE_FOLDER);
if (ideaDir != null && ideaDir.isValid() && ideaDir.isDirectory()) {
final File nameFile = new File(ideaDir.getPath(), ".name");
try {
FileUtil.writeToFile(nameFile, getName().getBytes("UTF-8"), false);
myOldName = null;
}
catch (IOException e) {
LOG.info("Unable to store project name to: " + nameFile.getPath());
}
}
}
}
StoreUtil.doSave(getStateStore());
}
catch (IComponentStore.SaveCancelledException e) {
LOG.info(e);
}
catch (PluginException e) {
PluginManager.disablePlugin(e.getPluginId().getIdString());
Notification notification = new Notification(
PLUGIN_SETTINGS_ERROR,
"Unable to save plugin settings!",
"<p>The plugin <i>" + e.getPluginId() + "</i> failed to save settings and has been disabled. Please restart" +
ApplicationNamesInfo.getInstance().getFullProductName() + "</p>" +
(ApplicationManagerEx.getApplicationEx().isInternal() ? "<p>" + StringUtil.getThrowableText(e) + "</p>" : ""),
NotificationType.ERROR);
Notifications.Bus.notify(notification, this);
LOG.info("Unable to save plugin settings",e);
}
catch (IOException e) {
MessagesEx.error(this, ProjectBundle.message("project.save.error", e.getMessage())).showLater();
LOG.info("Error saving project", e);
} finally {
mySavingInProgress.set(false);
ApplicationManager.getApplication().getMessageBus().syncPublisher(ProjectSaved.TOPIC).saved(this);
}
StoreUtil.doSave(getStateStore());
}
catch (IComponentStore.SaveCancelledException e) {
LOG.info(e);
}
catch (PluginException e) {
PluginManager.disablePlugin(e.getPluginId().getIdString());
Notification notification = new Notification(
PLUGIN_SETTINGS_ERROR,
"Unable to save plugin settings!",
"<p>The plugin <i>" + e.getPluginId() + "</i> failed to save settings and has been disabled. Please restart" +
ApplicationNamesInfo.getInstance().getFullProductName() + "</p>" +
(ApplicationManagerEx.getApplicationEx().isInternal() ? "<p>" + StringUtil.getThrowableText(e) + "</p>" : ""),
NotificationType.ERROR);
Notifications.Bus.notify(notification, this);
LOG.info("Unable to save plugin settings",e);
}
catch (IOException e) {
MessagesEx.error(this, ProjectBundle.message("project.save.error", e.getMessage())).showLater();
LOG.info("Error saving project", e);
} finally {
mySavingInProgress.set(false);
ApplicationManager.getApplication().getMessageBus().syncPublisher(ProjectSaved.TOPIC).saved(this);
}
}
@@ -23,6 +23,7 @@ import com.intellij.util.messages.MessageBus
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.util.Condition
import com.intellij.openapi.util.Key
import org.jetbrains.annotations.NotNull
/**
*
@@ -36,6 +37,7 @@ class GitMockProject implements Project {
myProjectDir = projectDir
}
@NotNull
@Override
String getName() {
throw new UnsupportedOperationException()
@@ -56,6 +58,7 @@ class GitMockProject implements Project {
throw new UnsupportedOperationException()
}
@NotNull
@Override
String getProjectFilePath() {
throw new UnsupportedOperationException()
@@ -71,6 +74,7 @@ class GitMockProject implements Project {
throw new UnsupportedOperationException()
}
@NotNull
@Override
String getLocationHash() {
throw new UnsupportedOperationException()