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 Point mLastRelMousePos;
|
||||||
public int32 mMouseStillTicks;
|
public int32 mMouseStillTicks;
|
||||||
public Widget mLastMouseWidget;*/
|
public Widget mLastMouseWidget;*/
|
||||||
|
public bool mAppHasFocus;
|
||||||
public int32 mCloseDelay;
|
public int32 mCloseDelay;
|
||||||
public FileChangedDialog mFileChangedDialog;
|
public FileChangedDialog mFileChangedDialog;
|
||||||
public FindAndReplaceDialog mFindAndReplaceDialog;
|
public FindAndReplaceDialog mFindAndReplaceDialog;
|
||||||
|
@ -2867,6 +2868,8 @@ namespace IDE
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
mWorkspace.mProjectFileEnties.Add(new .(workspaceFileName));
|
||||||
|
|
||||||
if (mVerb == .New)
|
if (mVerb == .New)
|
||||||
{
|
{
|
||||||
OutputErrorLine("Workspace '{0}' already exists, but '-new' argument was specified.", workspaceFileName);
|
OutputErrorLine("Workspace '{0}' already exists, but '-new' argument was specified.", workspaceFileName);
|
||||||
|
@ -2945,6 +2948,20 @@ namespace IDE
|
||||||
MarkDirty();
|
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)
|
public void GetRelaunchCmd(bool safeMode, String outRelaunchCmd)
|
||||||
{
|
{
|
||||||
if (mWorkspace.mDir != null)
|
if (mWorkspace.mDir != null)
|
||||||
|
@ -5175,6 +5192,12 @@ namespace IDE
|
||||||
mSettings.Apply();
|
mSettings.Apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CheckReloadSettings()
|
||||||
|
{
|
||||||
|
if (mSettings.WantsReload())
|
||||||
|
ReloadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
[IDECommand]
|
[IDECommand]
|
||||||
public void ResetUI()
|
public void ResetUI()
|
||||||
{
|
{
|
||||||
|
@ -13843,6 +13866,44 @@ namespace IDE
|
||||||
for (var window in mWindows)
|
for (var window in mWindows)
|
||||||
appHasFocus |= window.mHasFocus;
|
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)
|
if (mRunningTestScript)
|
||||||
appHasFocus = true;
|
appHasFocus = true;
|
||||||
|
|
||||||
|
|
|
@ -1534,6 +1534,11 @@ namespace IDE
|
||||||
Save();
|
Save();
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
if (mProjectName != null)
|
||||||
|
{
|
||||||
|
gApp.mWorkspace.mProjectFileEnties.Add(new .(path, mProjectName));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1091,6 +1091,8 @@ namespace IDE
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool mLoadedSettings;
|
public bool mLoadedSettings;
|
||||||
|
public String mSettingFileText ~ delete _;
|
||||||
|
public DateTime mSettingFileDateTime;
|
||||||
|
|
||||||
public UISettings mUISettings = new .() ~ delete _;
|
public UISettings mUISettings = new .() ~ delete _;
|
||||||
public EditorSettings mEditorSettings = new .() ~ delete _;
|
public EditorSettings mEditorSettings = new .() ~ delete _;
|
||||||
|
@ -1177,7 +1179,29 @@ namespace IDE
|
||||||
|
|
||||||
String dataStr = scope String();
|
String dataStr = scope String();
|
||||||
sd.ToTOML(dataStr);
|
sd.ToTOML(dataStr);
|
||||||
gApp.SafeWriteTextFile(path, 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()
|
public void Load()
|
||||||
|
@ -1189,6 +1213,13 @@ namespace IDE
|
||||||
if (sd.Load(path) case .Err)
|
if (sd.Load(path) case .Err)
|
||||||
return;
|
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;
|
mLoadedSettings = true;
|
||||||
using (sd.Open("UI"))
|
using (sd.Open("UI"))
|
||||||
mUISettings.Deserialize(sd);
|
mUISettings.Deserialize(sd);
|
||||||
|
|
|
@ -49,6 +49,37 @@ namespace IDE
|
||||||
[Reflect(.StaticFields | .NonStaticFields | .ApplyToInnerTypes)]
|
[Reflect(.StaticFields | .NonStaticFields | .ApplyToInnerTypes)]
|
||||||
public class Workspace
|
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
|
public enum IntermediateType
|
||||||
{
|
{
|
||||||
Object,
|
Object,
|
||||||
|
@ -459,6 +490,7 @@ namespace IDE
|
||||||
public List<WorkspaceFolder> mWorkspaceFolders = new List<WorkspaceFolder>() ~ DeleteContainerAndItems!(_);
|
public List<WorkspaceFolder> mWorkspaceFolders = new List<WorkspaceFolder>() ~ DeleteContainerAndItems!(_);
|
||||||
public List<Project> mProjects = new List<Project>() ~ DeleteContainerAndItems!(_);
|
public List<Project> mProjects = new List<Project>() ~ DeleteContainerAndItems!(_);
|
||||||
public List<ProjectSpec> mProjectSpecs = new .() ~ DeleteContainerAndItems!(_);
|
public List<ProjectSpec> mProjectSpecs = new .() ~ DeleteContainerAndItems!(_);
|
||||||
|
public List<ProjectFileEntry> mProjectFileEnties = new .() ~ DeleteContainerAndItems!(_);
|
||||||
public Dictionary<String, Project> mProjectNameMap = new .() ~ DeleteDictionaryAndKeys!(_);
|
public Dictionary<String, Project> mProjectNameMap = new .() ~ DeleteDictionaryAndKeys!(_);
|
||||||
public Dictionary<String, Lock> mProjectLockMap = new .() ~ DeleteDictionaryAndKeysAndValues!(_);
|
public Dictionary<String, Lock> mProjectLockMap = new .() ~ DeleteDictionaryAndKeysAndValues!(_);
|
||||||
public Project mStartupProject;
|
public Project mStartupProject;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue