diff --git a/uppsrc/ide/Browser/Move.cpp b/uppsrc/ide/Browser/Move.cpp index 0e40ad922..a234c3a23 100644 --- a/uppsrc/ide/Browser/Move.cpp +++ b/uppsrc/ide/Browser/Move.cpp @@ -12,12 +12,29 @@ public: void MoveTopicDlg::Package() { - + String g = ~group; + group.Clear(); + group.Add("src", "Reference (src)"); + group.Add("srcdoc", "Documents (srcdoc)"); + group.Add("srcimp", "Implementation (srcimp)"); + FindFile ff(SourcePath(~package, "*.tpp")); + while(ff) { + if(ff.IsFolder()) { + String h = GetFileTitle(ff.GetName()); + if(h != "src" && h != "srcdoc" && h != "srcimp") + group.Add(h); + } + ff.Next(); + } + if(group.HasKey(g)) + group <<= g; + else + group.GoBegin(); } MoveTopicDlg::MoveTopicDlg() { - CtrlLayoutOKCancel(*this, ""); + CtrlLayoutOKCancel(*this, "Move topic"); topic.NotNull(); topic.MaxLen(30); @@ -27,35 +44,41 @@ MoveTopicDlg::MoveTopicDlg() const Workspace& w = GetIdeWorkspace(); for(int i = 0; i < w.GetCount(); i++) package.Add(w[i]); + package.GoBegin(); + Package(); } void TopicEditor::MoveTopic() { - if(!topic.IsCursor()) - return; - - TopicDlg > d("Move topic"); + MoveTopicDlg dlg; String p = GetCurrentTopicPath(); + TopicLink tl = ParseTopicFilePath(p); + dlg.package <<= tl.package; + dlg.Package(); + dlg.group <<= tl.group; String tn; int lng; ParseTopicFileName(p, tn, lng); - d.topic <<= tn; - d.lang <<= lng; - if(d.Run() != IDOK) + dlg.topic <<= tn; + dlg.lang <<= lng; + if(dlg.Run() != IDOK) return; - String np = AppendFileName(grouppath, d.GetName()); + String np = AppendFileName(SourcePath(~dlg.package, (String)~dlg.group + ".tpp"), + (String)~dlg.topic + "$" + ToLower(LNGAsText(~dlg.lang)) + ".tpp"); if(FindFile(np)) { - Exclamation("Target file aready exists!"); - return; + if(!PromptYesNo("Target file aready exists!&Do you want to overwrite it?")) + return; + FileDelete(np); } Flush(); - FileMove(p, np); + RealizeDirectory(GetFileFolder(np)); + if(!SaveFile(np, LoadFile(p))) { + Exclamation("Operation failed!"); + return; + } + serial++; + FileDelete(p); InvalidateTopicInfoPath(p); InvalidateTopicInfoPath(np); - Open(grouppath); - Load(np); - SaveInc(); - topic.FindSetCursor(GetFileTitle(np)); - editor.SetFocus(); - serial++; + TheIde()->IdeOpenTopicFile(np); } diff --git a/uppsrc/ide/Browser/Topic.lay b/uppsrc/ide/Browser/Topic.lay index 2c1887eb1..050aeea6f 100644 --- a/uppsrc/ide/Browser/Topic.lay +++ b/uppsrc/ide/Browser/Topic.lay @@ -8,17 +8,17 @@ LAYOUT(NewTopicLayout, 268, 92) ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(196, 64).TopPosZ(60, 24)) END_LAYOUT -LAYOUT(MoveTopicLayout, 184, 136) +LAYOUT(MoveTopicLayout, 220, 136) ITEM(Label, dv___0, SetLabel(t_("Package")).LeftPosZ(8, 48).TopPosZ(4, 19)) - ITEM(DropList, package, LeftPosZ(68, 108).TopPosZ(4, 19)) + ITEM(DropList, package, LeftPosZ(68, 144).TopPosZ(4, 19)) ITEM(Label, dv___2, SetLabel(t_("Group")).LeftPosZ(8, 48).TopPosZ(28, 19)) - ITEM(DropList, group, LeftPosZ(68, 108).TopPosZ(28, 19)) + ITEM(DropList, group, LeftPosZ(68, 144).TopPosZ(28, 19)) ITEM(Label, dv___4, SetLabel(t_("Name")).LeftPosZ(8, 60).TopPosZ(52, 19)) - ITEM(EditString, topic, LeftPosZ(68, 108).TopPosZ(52, 19)) + ITEM(EditString, topic, LeftPosZ(68, 144).TopPosZ(52, 19)) ITEM(Label, dv___6, SetLabel(t_("Language")).LeftPosZ(8, 60).TopPosZ(76, 19)) ITEM(LNGCtrl, lang, LeftPosZ(68, 108).TopPosZ(76, 19)) - ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(44, 64).TopPosZ(104, 24)) - ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(112, 64).TopPosZ(104, 24)) + ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(80, 64).TopPosZ(104, 24)) + ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(148, 64).TopPosZ(104, 24)) END_LAYOUT LAYOUT(TemplateListLayout, 236, 376) diff --git a/uppsrc/ide/Common/Common.h b/uppsrc/ide/Common/Common.h index 5fb1bdc12..ec941c30f 100644 --- a/uppsrc/ide/Common/Common.h +++ b/uppsrc/ide/Common/Common.h @@ -66,7 +66,7 @@ public: virtual bool IdeIsDebugLock() const = 0; virtual void IdeSetBar() = 0; virtual void IdeGotoCodeRef(String link) = 0; - virtual void IdeMoveTopic(const String& from, const String& to) = 0; + virtual void IdeOpenTopicFile(const String& file) = 0; virtual ~IdeContext() {} }; diff --git a/uppsrc/ide/ide.h b/uppsrc/ide/ide.h index aefca055c..5d9a552f4 100644 --- a/uppsrc/ide/ide.h +++ b/uppsrc/ide/ide.h @@ -524,7 +524,7 @@ public: virtual void IdeSetBar(); virtual void IdeGotoCodeRef(String coderef); - virtual void IdeMoveTopic(const String& from, const String& to); + virtual void IdeOpenTopicFile(const String& file); enum { EDITING, BUILDING, RUNNING, DEBUGGING, diff --git a/uppsrc/ide/idetool.cpp b/uppsrc/ide/idetool.cpp index 18c4b894b..655b6367e 100644 --- a/uppsrc/ide/idetool.cpp +++ b/uppsrc/ide/idetool.cpp @@ -84,7 +84,7 @@ void Ide::OpenTopic(const char *topic) if(designer) { TopicEditor *te = dynamic_cast(&designer->DesignerCtrl()); if(te) - te->GoTo(tl.topic, doc.GetCurrentLabel()); + te->GoTo(tl.topic, tl.label); } } } @@ -97,13 +97,14 @@ void Ide::OpenATopic() OpenTopic(t); } -void Ide::IdeMoveTopic(const String& from, const String& to) +void Ide::IdeOpenTopicFile(const String& file) { - if(to != from) { - Upp::SaveFile(to, LoadFile(from)); - FileDelete(from); + EditFile(GetFileFolder(file)); + if(designer) { + TopicEditor *te = dynamic_cast(&designer->DesignerCtrl()); + if(te) + te->GoTo(GetFileName(file), ""); } - OpenTopic(to); } void Ide::InsertColor()