mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-21 01:18:02 +02:00
Better setting/project/workspace handling of concurrent IDE instances
This commit is contained in:
parent
fe5cae2220
commit
d3ca45d80a
4 changed files with 130 additions and 1 deletions
|
@ -320,6 +320,7 @@ namespace IDE
|
|||
public Point mLastRelMousePos;
|
||||
public int32 mMouseStillTicks;
|
||||
public Widget mLastMouseWidget;*/
|
||||
public bool mAppHasFocus;
|
||||
public int32 mCloseDelay;
|
||||
public FileChangedDialog mFileChangedDialog;
|
||||
public FindAndReplaceDialog mFindAndReplaceDialog;
|
||||
|
@ -2867,6 +2868,8 @@ namespace IDE
|
|||
}
|
||||
else
|
||||
{
|
||||
mWorkspace.mProjectFileEnties.Add(new .(workspaceFileName));
|
||||
|
||||
if (mVerb == .New)
|
||||
{
|
||||
OutputErrorLine("Workspace '{0}' already exists, but '-new' argument was specified.", workspaceFileName);
|
||||
|
@ -2945,6 +2948,20 @@ namespace IDE
|
|||
MarkDirty();
|
||||
}
|
||||
|
||||
protected void ReloadWorkspace()
|
||||
{
|
||||
SaveWorkspaceUserData(false);
|
||||
|
||||
String workspaceDir = scope .(mWorkspace.mDir);
|
||||
String workspaceName = scope .(mWorkspace.mName);
|
||||
|
||||
CloseWorkspace();
|
||||
mWorkspace.mDir = new String(workspaceDir);
|
||||
mWorkspace.mName = new String(workspaceName);
|
||||
LoadWorkspace(.Open);
|
||||
FinishShowingNewWorkspace();
|
||||
}
|
||||
|
||||
public void GetRelaunchCmd(bool safeMode, String outRelaunchCmd)
|
||||
{
|
||||
if (mWorkspace.mDir != null)
|
||||
|
@ -5175,6 +5192,12 @@ namespace IDE
|
|||
mSettings.Apply();
|
||||
}
|
||||
|
||||
public void CheckReloadSettings()
|
||||
{
|
||||
if (mSettings.WantsReload())
|
||||
ReloadSettings();
|
||||
}
|
||||
|
||||
[IDECommand]
|
||||
public void ResetUI()
|
||||
{
|
||||
|
@ -13843,6 +13866,44 @@ namespace IDE
|
|||
for (var window in mWindows)
|
||||
appHasFocus |= window.mHasFocus;
|
||||
|
||||
if ((appHasFocus) && (!mAppHasFocus))
|
||||
{
|
||||
CheckReloadSettings();
|
||||
|
||||
bool hadChange = false;
|
||||
for (var entry in mWorkspace.mProjectFileEnties)
|
||||
{
|
||||
if (entry.HasFileChanged())
|
||||
{
|
||||
if (!hadChange)
|
||||
{
|
||||
String text = scope .();
|
||||
|
||||
if (entry.mProjectName != null)
|
||||
text.AppendF($"The '{entry.mProjectName}' project file has been modified externally.");
|
||||
else
|
||||
text.Append("The workspace file has been modified externally.");
|
||||
|
||||
text.Append("\n\nDo you want to reload the workspace?");
|
||||
|
||||
var dialog = ThemeFactory.mDefault.CreateDialog("Reload Workspace?",
|
||||
text);
|
||||
dialog.AddYesNoButtons(new (dlg) =>
|
||||
{
|
||||
ReloadWorkspace();
|
||||
},
|
||||
new (dlg) =>
|
||||
{
|
||||
|
||||
});
|
||||
dialog.PopupWindow(GetActiveWindow());
|
||||
hadChange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mAppHasFocus = appHasFocus;
|
||||
|
||||
if (mRunningTestScript)
|
||||
appHasFocus = true;
|
||||
|
||||
|
|
|
@ -1534,6 +1534,11 @@ namespace IDE
|
|||
Save();
|
||||
}*/
|
||||
|
||||
if (mProjectName != null)
|
||||
{
|
||||
gApp.mWorkspace.mProjectFileEnties.Add(new .(path, mProjectName));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1091,6 +1091,8 @@ namespace IDE
|
|||
}
|
||||
|
||||
public bool mLoadedSettings;
|
||||
public String mSettingFileText ~ delete _;
|
||||
public DateTime mSettingFileDateTime;
|
||||
|
||||
public UISettings mUISettings = new .() ~ delete _;
|
||||
public EditorSettings mEditorSettings = new .() ~ delete _;
|
||||
|
@ -1177,7 +1179,29 @@ namespace IDE
|
|||
|
||||
String dataStr = scope String();
|
||||
sd.ToTOML(dataStr);
|
||||
|
||||
if ((mSettingFileText == null) || (mSettingFileText != dataStr))
|
||||
{
|
||||
String.NewOrSet!(mSettingFileText, dataStr);
|
||||
gApp.SafeWriteTextFile(path, dataStr);
|
||||
|
||||
if (File.GetLastWriteTime(path) case .Ok(let dt))
|
||||
mSettingFileDateTime = dt;
|
||||
}
|
||||
}
|
||||
|
||||
public bool WantsReload()
|
||||
{
|
||||
String path = scope .();
|
||||
GetSettingsPath(path);
|
||||
|
||||
if (File.GetLastWriteTime(path) case .Ok(let dt))
|
||||
{
|
||||
if (dt != mSettingFileDateTime)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Load()
|
||||
|
@ -1189,6 +1213,13 @@ namespace IDE
|
|||
if (sd.Load(path) case .Err)
|
||||
return;
|
||||
|
||||
if (File.GetLastWriteTime(path) case .Ok(let dt))
|
||||
mSettingFileDateTime = dt;
|
||||
|
||||
String.NewOrSet!(mSettingFileText, sd.[Friend]mSource);
|
||||
mSettingFileText.Replace("\r\n", "\n");
|
||||
mSettingFileText.Replace('\r', '\n');
|
||||
|
||||
mLoadedSettings = true;
|
||||
using (sd.Open("UI"))
|
||||
mUISettings.Deserialize(sd);
|
||||
|
|
|
@ -49,6 +49,37 @@ namespace IDE
|
|||
[Reflect(.StaticFields | .NonStaticFields | .ApplyToInnerTypes)]
|
||||
public class Workspace
|
||||
{
|
||||
public class ProjectFileEntry
|
||||
{
|
||||
public String mPath = new .() ~ delete _;
|
||||
public DateTime mLastWriteTime;
|
||||
public String mProjectName ~ delete _;
|
||||
|
||||
public this(StringView path, StringView projectName = null)
|
||||
{
|
||||
mPath.Set(path);
|
||||
if (projectName != default)
|
||||
mProjectName = new .(projectName);
|
||||
if (File.GetLastWriteTime(mPath) case .Ok(var dt))
|
||||
mLastWriteTime = dt;
|
||||
}
|
||||
|
||||
public bool HasFileChanged()
|
||||
{
|
||||
if (mLastWriteTime == default)
|
||||
return false;
|
||||
if (File.GetLastWriteTime(mPath) case .Ok(var dt))
|
||||
{
|
||||
if (dt != mLastWriteTime)
|
||||
{
|
||||
mLastWriteTime = dt;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public enum IntermediateType
|
||||
{
|
||||
Object,
|
||||
|
@ -459,6 +490,7 @@ namespace IDE
|
|||
public List<WorkspaceFolder> mWorkspaceFolders = new List<WorkspaceFolder>() ~ DeleteContainerAndItems!(_);
|
||||
public List<Project> mProjects = new List<Project>() ~ DeleteContainerAndItems!(_);
|
||||
public List<ProjectSpec> mProjectSpecs = new .() ~ DeleteContainerAndItems!(_);
|
||||
public List<ProjectFileEntry> mProjectFileEnties = new .() ~ DeleteContainerAndItems!(_);
|
||||
public Dictionary<String, Project> mProjectNameMap = new .() ~ DeleteDictionaryAndKeys!(_);
|
||||
public Dictionary<String, Lock> mProjectLockMap = new .() ~ DeleteDictionaryAndKeysAndValues!(_);
|
||||
public Project mStartupProject;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue